2011-01-07 4 views

Respuesta

23

Esto es algo que se hace en Linux mucho:

#!/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 
Cuestiones relacionadas