Hello All,
On some purpose I wrote two small programs
start.cgi and
server.cgi:
start.cgi
#!/usr/bin/perl -w
open(PID, "< pid") || die "Can't open PID file: $!";
$pid = <PID>;
close PID;
if(defined $pid){
if($pid==0){
# print "Location: http://test/test.html \n\n";
print "Content-type: text/html\n\n";
print "<html>hello<html>";
exec '/usr/sites/test/vcgi/server.cgi';
}
}
server.cgi
#!/usr/bin/perl -w
# use IO::Socket;
open(PID, "> pid") || die "Can't open PID file: $!";
print PID $$ ;
close PID;
Both programs and
pid file are located at '/usr/sites/test/vcgi' which is set as 'cgi-bin' dir in Apache config file.
Start.cgi is executed from a browser. It checks if
server.cgi is on (reading pid file) runs it if it's not and returns 'hello'. At the beginning
pid file contains '0'.
test.html page contains nothing but
html and
body tags
The problem.
Programs work fine until I remove comments from 'use..' statement in
server.cgi OR replace two print statements with 'Location...' one in
start.cgi.
If I do any of those
server.cgi writes nothing into
pid and I'm not sure if it's executed at all.
If I run start.cgi from shell everything works fine with 'use..' and 'Location...'.
I don't undertand this at all and will be appreciated if anyone tell me where the source of this problem might be.
Thank you.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.