I need to check for the presence of STDIN input in a Ruby script, like the mysql command can. If nothing is being directed to STDIN, then the script should not
mysql
This is something that's done in Linux a lot:
#!/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