Firstly, welcome to Perl Monks. Secondly, when posting there is advice displayed on how to format your post correctly, to make it easy for everyone to read. Please don't ignore this advice. For further info see How do I post a question effectively?.

Looking at your code the first thing I'd say is that you don't have:

use strict; use warnings;

anywhere. This should be at the start of your script, after the shebang line. Read Use strict and warnings from the tutorials section.

Is there a reason you aren't using CGI? See Ovid'sCGI Course and CGI Programming from the tutorials section of this site.

Have you checked the Apache error_log file to see what it says? It's a good place to start investigating such issues :)

Common reasons for shell scripts not running via CGI scripts include:

Insufficient privileges: does your shell script work from the command line when executed as the user running your web server/CGI scripts?

OS based security: Some web servers such as IIS6 won't execute shell or command line scripts out of the box. Is your web server configured correctly? Are you (or more to the point the server on which this script resides) running Security-Enhanced_Linux?

Martin


In reply to Re: Execution of shell script failing always inside cgi based perl program by marto
in thread Execution of shell script failing always inside cgi based perl program by Siva

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.