Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: problem with system(), stdin, and stdout

by Animator (Hermit)
on Sep 29, 2008 at 21:15 UTC ( [id://714421]=note: print w/replies, xml ) Need Help??


in reply to problem with system(), stdin, and stdout

Does your code contain close STDIN;? If yes, does it also contain: open STDIN, "<", "/dev/null";?

Replies are listed 'Best First'.
Re^2: problem with system(), stdin, and stdout
by romero619 (Novice) on Sep 30, 2008 at 01:41 UTC
    Nevermind...stupid yet subtle mistake...
    I wasnt chomping the result from STDIN...
    should have done this:
    chomp($filename=<STDIN>);

    this removes the newline character which kept getting inserted into $filename, giving $filename a value such as '/path/file\n', and thus passing the newline into my $cmd string, making $cmd look like this:

    $cmd = "mycmd -args $filename >outfile"
    ...gives...
    "mycmd -args /path/file\n >outfile"

    So, everytime I passed $cmd to system(), it would execute the cmd and stop at the newline character embedded within $filename, thus skipping the ">outfile" redirection...

    problem solved, but thanks to everyone for pointing out that this apparently should have worked.
    Please add this to your vast collection of mental "gotchas" that can stump users...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://714421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-26 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found