Forum: Ruby backtick vs. system()

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2007-06-18 19:21
(Received via mailing list)

I have problems with the difference between the system() call and a
backtick call `command`.

Everything work fine until I try to redirect the output of the script.

puts `ls`

A normal run is fine.
The redirected version with   test.rb >test.log 2>&1    stops with
"bad file descriptor".
If you try the command independent, you will see that system() causes
the problem.
Any hints?

I used system, due I can see the output during the run.
With puts `ls` it will be only visible at the end.

Jeremy T. (Guest)
on 2007-06-18 19:49
(Received via mailing list)
Try using IO#popen instead.

Jeremy T.
This topic is locked and can not be replied to.