Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use CGI qw(:standard); $| = 1; if (my $pid = fork) { #parent does close STDOUT; close STDIN; close STDERR; open STDIN, '<', '/dev/null'; open STDOUT, '>', '/dev/null'; my $err_file = "/var/www/html/cgi_data/error_log"; open STDERR, '>', $err_file; start_x(); } else { print header(), q~ <HTML> <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="3; URL=/cgi_data/page1.html"> <TITLE>New Site notification</TITLE> </HEAD> <BODY>My homepage has moved to a new location. I am here</BODY></HTML> ~; exit; } sub start_x { $com = "./myprog 100"; open PIPE, "$com |"; $outfile1 = "../html/cgi_data/page2.html"; open OUT, ">$outfile1" or die "Can not open for write: $outfile"; while ($data = <PIPE>) { print OUT "$data\n"; } close OUT; }
open PIPE, "$com |";
I tried to put a print STDERR "I am here"; and noticed it does print to the
error_log file if I put the print statement above the open PIPE but does not if
I put the print statement after it. Any thoughts?
Thanks.
Code tags added by GrandFather
|
|---|