hi

I've written this perl script:
#!/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);

this script shoul execute the shell startup script,
but it won't work.

from command line I get following error:
# 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>

I really don't understand, what's wrong.
the paths are correct and files are executable.

kind regards
cc

In reply to perl script using sudo by cc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.