in reply to Re^4: show a message only during the sleep time
in thread show a message only during the sleep time

well, obvious question is, do you have a 'EOF' line in your code? :) Note that the string "EOF" is arbitrary, too. Search for "here-document" in perldoc perldata for more info, but two simple examples:
print <<EOF; Hello World !!! EOF print <<BLAH; Hello World !!! BLAH
If you still have problems, please post the code along w/the error message.

Replies are listed 'Best First'.
Re^6: show a message only during the sleep time
by cc (Beadle) on Jul 24, 2005 at 21:59 UTC
    I've got this error message before,
    because I must edit this sript directly on the unix machine.
    If I edit on the windoze and transfer to unix,
    I get this error message.
    anyway this script works only from command line:
    #!/usr/bin/perl -w use strict; use warnings; use CGI; my $query = new CGI; use CGI::Carp qw(fatalsToBrowser); $|=1; print <<EOF; <html> <head> <title>ntop startup script</title> <STYLE TYPE='text/css'> h3 { color: red } a { text-decoration: none; font: bold 14pt/16pt Ariel, serif } a:hover { color: red } /* when mouse is over link */ </style> <script language="javascript"> function hideWaitMsg(){ var obj = getElementById('wait_msg_text'); obj.visible = false; } </script> </head> <body bgcolor='#c0c0d0' onLoad="hideWaitMsg()"> <center> <p><br></p> <p><br></p> <div id="wait_msg_text">pls wait, ntop will be started</div> EOF system `/usr/local/www/cgi-bin/ntop/ntop.sh stop` or die "cannot stop +ntop: $!"; sleep(8); my $cc = `sudo /usr/local/www/cgi-bin/ntop/ntop.sh start` or die "cann +ot start ntop: $!"; print "<font face=\"arial,helvetica\" size=2 color=\"#006600\">status: +</font> ",$cc,"<br><br>\n"; print "<font face=\"arial,helvetica\" size=2 color=\"#FF0000\"> pls do not forget to shutdown, if you're not using </font> \n"; print "\n"; print "<p><br></p>"; print "pls wait for 5 seconds before you click on this link:\n"; print "<br><br>"; print "<a href=\"https://192.168.0.3:3001\"><b><U>NTOP</b></U></a>\n"; print "<p><br></p>"; print "<p><br></p>"; print "<p><br></p>"; print "<p><br></p>"; print "Maintained by <a href=\"mailto:admin@\domain.net\"><font face=\ +"arial,helvetica\" size=3> admin</a></font>\n"; print "</center>"; print "</body>"; print "</html>"; exit($cc);

    In the browser I get:
    "Internal Server Error"
    It seems the whole HTML code must be inside of
    print <<EOF;
    EOF
      • the windows/unix is clearly newlines .. be sure to convert properly (it might be your ftp client, too--make sure it's doing ascii mode)
      • You don't have to have the whole thing inside of a here-doc
      • the internal server error is likely (if it's not the next item) due to lack of headers. What is in the web server's error_log? when run on cmd line, what is the exact output?
      • (this could also be the server error) You shouldn't be exit'ing a cgi program like that... just remove that line. the web server might be server erroring because of that return code.
        I removed this line:
        exit($cc);
        and still get the same error in the browser

        from command line:
        # perl ntop4.cgi + [Mon Jul 25 14:27:27 2005] ntop4.cgi: Unrecognized escape \d passed th +rough at ntop4.cgi line 53. <html> <head> <title>ntop startup script</title> <STYLE TYPE='text/css'> h3 { color: red } a { text-decoration: none; font: bold 14pt/16pt Ariel, serif } a:hover { color: red } /* when mouse is over link */ </style> <script language="javascript"> function hideWaitMsg(){ var obj = getElementById('wait_msg_text'); obj.visible = false; } </script> </head> <body bgcolor='#c0c0d0' onLoad="hideWaitMsg()"> <center> <p><br></p> <p><br></p> <div id="wait_msg_text">pls wait, ntop will be started</div> Mon Jul 25 14:27:28 2005 Initializing gdbm databases <font face="arial,helvetica" size=2 color="#006600">status: +</font> ntop<br><br> <font face="arial,helvetica" size=2 color="#FF0000"> pls do not forget to shutdown, if you're not using </font> <p><br></p>pls wait for 5 seconds before you click on this link: <br><br><a href="https://192.168.0.3:3001"><b><U>NTOP</b></U></a> <p><br></p><p><br></p><p><br></p><p><br></p>Maintained by <a href="mai +lto:admin@domain.net"><font face="arial,helvetica" size=3> admin</a></font> </center></body></html>

        Apache error log says:
        [Mon Jul 25 14:30:04 2005] [error] [client 192.168.0.105] [Mon Jul 25 +14:30:04 2005] ntop4.cgi: Unrecognized escape \\d passed through at / +usr/local/www/cgi-bin/ntop/ntop4.cgi line 53. [Mon Jul 25 14:30:04 2005] [error] [client 192.168.0.105] malformed he +ader from script. Bad header=<html>: ntop4.cgi
        greetings cc