in reply to How to hide system(); output.
Maybe the default "cmd.exe" (or whatever gets used on windows to run commands via the system() call) provides some equivalent sort of idiom, if you know how to look that up... (or maybe you can set things up so that your "do this, and do that" stuff gets run via a bash.exe shell, so you can at least redirect output to some file that you can then delete -- possibly after reading it to check for error conditions?)$command = "(do this && do that) >/dev/null 2>&1";
Apart from that, since the main problem is the fact that your perl script is running in an environment where all output to STDOUT goes to some browser client, what you have to do is to change the STDOUT file handle so that stuff written to that handle will end up somewhere else, like a scalar variable (read the output of perldoc -f open):
UPDATE: the above snippet was not tested, and on testing it, it doesn't work as intended. See ikegami's reply to me.close STDOUT; open STDOUT, '>', \$variable; system( $command ); close STDOUT; # you might want to check what got put into $variable... open STDOUT, '>-'; # reopen the real stdout
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to hide system(); output.
by ikegami (Patriarch) on Jan 30, 2010 at 04:40 UTC | |
by graff (Chancellor) on Jan 30, 2010 at 16:14 UTC | |
by Anonymous Monk on Aug 09, 2011 at 09:40 UTC | |
by Anonymous Monk on Aug 09, 2011 at 09:47 UTC | |
Re^2: How to hide system(); output.
by crashtest (Curate) on Jan 30, 2010 at 01:31 UTC | |
by bcens (Novice) on Jan 30, 2010 at 02:11 UTC |