Please excuse the simple question, but I am experimenting with TextMate and Ruby. The output from running a Ruby script goes to a stdout window. However, I can't figure out how to get input from the gets method. Is there any way to read from stdin when running a Ruby script from the Run Command>Ruby>Run Ruby menu?
Thanks for any help.
Bill Shobe
On 29/09/2005, at 16.28, William M Shobe wrote:
Please excuse the simple question, but I am experimenting with TextMate and Ruby. The output from running a Ruby script goes to a stdout window. However, I can't figure out how to get input from the gets method. Is there any way to read from stdin when running a Ruby script from the Run Command>Ruby>Run Ruby menu?
Yes, this happens automatically, but stdin is redirected to read input from a dialog which should pop up whenever your script does a gets or similar.
-- Sune.
stdout window. However, I can't figure out how to get input from the gets method. Is there any way to read from stdin when running a Ruby script from the Run Command>Ruby>Run Ruby menu?
Yes, this happens automatically, but stdin is redirected to read input from a dialog which should pop up whenever your script does a gets or similar.
Interesting. I didn't know about this feature. But I just tried it and stdin was sent as en empty string; there was no dialog. How do you have to set the command up? My test was like this:
Save=Nothing Command= #!/usr/bin/env python
import sys for line in sys.stdin.readlines(): print line print "done"
Input=None Output=Show in separate window
obviously this same script run in the shell will wait for input and will finish when you send it ^D (end of file). I tried it with readline too, but the same thing: no dialog and just an empty string. Like :
#!/usr/bin/env python
import sys print sys.stdin.readline().strip() print "done"
oh, hehe, it is just the Run Ruby command. Sorry, I thought you meant this was built into TextMate!
On 9/29/05, Kumar McMillan kumar.mcmillan@gmail.com wrote:
stdout window. However, I can't figure out how to get input from the gets method. Is there any way to read from stdin when running a Ruby script from the Run Command>Ruby>Run Ruby menu?
Yes, this happens automatically, but stdin is redirected to read input from a dialog which should pop up whenever your script does a gets or similar.
Interesting. I didn't know about this feature. But I just tried it and stdin was sent as en empty string; there was no dialog. How do you have to set the command up? My test was like this:
Save=Nothing Command= #!/usr/bin/env python
import sys for line in sys.stdin.readlines(): print line print "done"
Input=None Output=Show in separate window
obviously this same script run in the shell will wait for input and will finish when you send it ^D (end of file). I tried it with readline too, but the same thing: no dialog and just an empty string. Like :
#!/usr/bin/env python
import sys print sys.stdin.readline().strip() print "done"