#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use CGI; my $query = new CGI; # write the log BEGIN { use CGI::Carp qw(carpout); my $errorlog = "/var/tmp/errorlog.txt"; open(LOG, ">$errorlog") or die("Unable to open $errorlog: $!\n"); print LOG "Errors:\n"; carpout(*LOG); } print $query->header; print "<html>\n"; print "<head>\n"; print "<title>ntop startup script</title>\n"; print "<STYLE TYPE='text/css'>\n"; print "h3 { color: red }\n"; print "a { text-decoration: none; font: bold 14pt/16pt Ariel, serif }" +; print "a:hover { color: red } /* when mouse is over link */"; print "</style>\n"; print "</head>\n"; print "<body bgcolor='#c0c0d0'>\n"; print "<center>"; print "<p><br></p>"; print "<p><br></p>"; `sudo sh /usr/local/www/cgi-bin/ntop/ntop.sh stop` or die "cannot stop + ntop: $!"; sleep(8); $cc = `sudo sh /usr/local/www/cgi-bin/ntop/ntop.sh start` or die "cann +ot start ntop: $!"; print "Status: ",$cc,"\n"; print "</body>"; print "</html>"; exit($cc);
# perl ntop4.cgi Content-Type: text/html; charset=ISO-8859-1 <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> </head> <body bgcolor='#c0c0d0'> <center><p><br></p><p><br></p><h1>Software error:</h1> <pre>cannot stop ntop: No such file or directory at ntop4.cgi line 32. +</pre> <p> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. </p>
In reply to perl script using sudo by cc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |