Backtick vs. system()

Hi,

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.

Ex.
puts `ls`
system('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.

Thanks
   Peter

Try using IO#popen instead.

···

--
Jeremy Tregunna
jtregunna@blurgle.ca

On 18-Jun-07, at 11:20 AM, Peter.Meier998@gmx.de wrote:

Hi,

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.

Ex.
puts `ls`
system('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.

Thanks
   Peter

!DSPAM:4676a2c4533981744819530!