cc has asked for the wisdom of the Perl Monks concerning the following question:
#!/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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl script using sudo
by Nkuvu (Priest) on Jul 23, 2005 at 16:44 UTC | |
|
Re: perl script using sudo
by Crackers2 (Parson) on Jul 23, 2005 at 22:44 UTC | |
|
Re: perl script using sudo
by gam3 (Curate) on Jul 23, 2005 at 16:16 UTC | |
|
Re: perl script using sudo
by halley (Prior) on Jul 23, 2005 at 21:32 UTC | |
by cc (Beadle) on Jul 23, 2005 at 22:30 UTC | |
by Nkuvu (Priest) on Jul 23, 2005 at 23:22 UTC | |
by cc (Beadle) on Jul 24, 2005 at 01:01 UTC | |
by halley (Prior) on Jul 24, 2005 at 16:48 UTC |