sudo requires a password, unless you explicitly set it up in the sudoers file not to. My first guess is that when the script runs it doesn't feed a password to sudo (that's more than a guess, I can see that the script doesn't) so the command fails. The guess part is that the call to sudo will either time out or go away when called from within Perl.

In addition I see future problems when you try to run this as a CGI program. The user that Apache runs under (guessing that you're using Apache as it looks like you're on a *n*x environment) doesn't have permission to run sudo at all.

I don't see this as a Perl or permissions error -- at least, not a file permissions error. First, I would ensure that the ntop shell script has the proper shebang line, and set it to be executable. Then I'd go over it with a fine tooth comb and see if it's secure. Then ask some others to take a look at it to be sure. When you're sure it doesn't have any security holes, you can set it up to run under sudo without a password in the sudoers file. Or find a different way to do what it is that you're doing.


In reply to Re: perl script using sudo by Nkuvu
in thread 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.