in reply to system() Creating Different Results than Commandline Operation.
By the way, what's with ">/dev/null" on Windows? That should be ">nul".
It's actually simpler to make it portable:
sub system_no_output { my $mode = shift; open(my $chld_in, '<&', *STDIN) or die($!); my $chld_out = '>&STDOUT'; my $chld_err = '>&STDERR'; open($chld_out=undef, '>', devnull()) or die($!) if $mode & 1; open($chld_err=undef, '>', devnull()) or die($!) if $mode & 2; my $pid = open3($chld_in, $chld_out, $chld_err, @_) or die($!); return waitpid($pid, 0); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: system() Creating Different Results than Commandline Operation.
by kazeits (Initiate) on Apr 06, 2009 at 18:02 UTC | |
by ikegami (Patriarch) on Apr 06, 2009 at 18:12 UTC |