



On Unix I can run commands like "foo.pl | bar.pl" and have the output of foo.pl be the input of bar.pl. This doesn't seem to work on Windows. How can I make this work?
The Windows command interpreter cmd.exe does not support IO redirection for programs started via shell associations, like those created for .pl files during the ActivePerl installation. It only works for .bat, .com, .cmd, and .exe files.
You need to write:
perl foo.pl | perl bar.pl
Or if the files are not in your current directory but are on the PATH:
perl -S foo.pl | perl -S bar.pl
Alternatively, you can wrap your .pl files into .bat scripts using pl2bat:
pl2bat foo.pl
pl2bat bar.pl
Then run them as:
a | b
This is also the case for > and <.
In UNIX I can run the following
$result = system("$sql_cmd > $output_file") ;
if(!open(SQL, " < $output_file ")) {
print "Error: output file not opened\n" ;
exit 1 ;
}
#
### Process file should happen here... but does not.
#
Why does this not work in Windows?
A) File exists.
B) Even a for loop trying to make successive open's does not work.
C) Files quoted well, all backslashes accounted for.
What can I do to make this $output_file visible to windows?
Best Wishes,
Don Turnblade
MS, CISSP