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.
33b18815ae674e4c3843ecb6e73b3f21?d=identicon&s=25 unknown (Guest)
on 2007-06-18 17: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.

96950c5dec0af04a5c12dae973e96cc7?d=identicon&s=25 Jeremy Tregunna (Guest)
on 2007-06-18 17:49
(Received via mailing list)
Try using IO#popen instead.

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