No. Consider
After the 2nd system there is one more cmd process, and @ARGV no longer contains out.txt, ie it is the shell that does redirection.#!/usr/bin/perl -- unlink 'out.txt'; system 1, $^X, '-MData::Dumper', '-le','print(1);warn(2);print Dumper( +\@ARGV);', '>out.txt 2>&1'; sleep 1; print `cat out.txt`, "\n",'-'x66,"\n"; sleep 1; print `pslist |grep -c cmd`,"\n",'-'x66,"\n"; system 1, 'perl.exe -MData::Dumper -le "print(1);warn(2);print `pslist + |grep -c cmd`, Dumper(\@ARGV)" >out.txt 2>&1'; sleep 1; print `cat out.txt`, "\n",'-'x66,"\n"; __END__ 1 2 at -e line 1. $VAR1 = [ '>out.txt 2>&1' ]; cat: out.txt: No such file or directory ------------------------------------------------------------------ pslist v1.28 - Sysinternals PsList Copyright ¬ 2000-2004 Mark Russinovich Sysinternals 8 ------------------------------------------------------------------ 2 at -e line 1. 1 pslist v1.28 - Sysinternals PsList Copyright ¬ 2000-2004 Mark Russinovich Sysinternals 9 $VAR1 = []; ------------------------------------------------------------------
You can use Proc::Background to launch processes in the background
In reply to Re^7: Test whether STDOUT is connected to a file
by Anonymous Monk
in thread Test whether STDOUT is connected to a file
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |