Under Co:Z Launcher I run a perl script.
Within the perl script I run the following, among other statements. I expected the contents of my file to appear in STDERR of my Co:Z job step STDERR DD sysout but the file content seems to go nowhere.
if (-e "myfile.txt"){
print "myfile exists\n";
my $rc = system("cat myfile.txt 1>&2");
}
I do get the message myfile exists in the STDOUT sysout of the job step.
When I run the above within the Co:Z shell I get the expect results, data is in STDERR. However I must run this command from within the perl script.
Thanks,
Scott
Redirect STDOUT to STDERR
What the Co:Z Launcher does is to run the system shell on the target server, with stdout and stderr directed to pipes that are routed back to z/OS DDs.
So, in this case the question is: when running this Perl script under the same shell, what is happening to stderr? The shell should dup the same stderr fd (the pipe) to the child Perl process, and Perl should give it to the process created by system(), so I'm at a loss.
I'm not a Perl expert, but the documentation for system():
http://perldoc.perl.org/functions/system.html
which says that if you give it one argument (like you did) that contains meta characters (which it seems to), then it should run your command with "/bin/sh -c".
Have you tried running the Perl script and proving that it works properly? Like:
If this doesn't work, then you have a Perl problem. What happens if you just run a command that will write something to system err, without a shell:
I suspect that you will find that the error message written to stderr will show up on DD:STDERR.
Maybe your version of Perl doesn't run the shell automaticaly for this command and you need to encourage it:
BTW: I tried the following to a target Linux box and it worked as expected:
So, in this case the question is: when running this Perl script under the same shell, what is happening to stderr? The shell should dup the same stderr fd (the pipe) to the child Perl process, and Perl should give it to the process created by system(), so I'm at a loss.
I'm not a Perl expert, but the documentation for system():
http://perldoc.perl.org/functions/system.html
which says that if you give it one argument (like you did) that contains meta characters (which it seems to), then it should run your command with "/bin/sh -c".
Have you tried running the Perl script and proving that it works properly? Like:
Code: Select all
./myPerlScript 2>myerr.txt
Code: Select all
my $d = system("rm file-that-does-not-exist");
Maybe your version of Perl doesn't run the shell automaticaly for this command and you need to encourage it:
Code: Select all
my $d = system("/bin/sh", "-c", "cat myfile.txt 1>&2");
Code: Select all
//RUNCOZK EXEC PROC=COZPROC,ARGS='kirk@xxx.yyy.zzz.qqqq'
//COZCFG DD *
saf-cert=SSH-RING
//STDIN DD *
perl -e 'system("echo foo 1>&2");'
//