2011-01-07 9 views

risposta

23

Questo è qualcosa che è fatto in Linux un sacco:

#!/usr/bin/env ruby 

str = (STDIN.tty?) ? 'not reading from stdin' : $stdin.read 
puts str 

>> $ ruby test.rb 
>> not reading from stdin 
>> $ echo "reading from stdin" | ruby test.rb 
>> reading from stdin 
Problemi correlati