Check permissions. for group and others
# ls -l ./script.cgi

Check who the cgi runs as.
add a line somewhere that says
print STDERR 'i am running as: '. `whoami`;
go to your terminal and do :
# tail -f /var/log/httpd/error_log then call the script from the browser- you'll see the messages as they come out.
Keep in mind your log may be elsewhere, but should be easy to find. If you are using ssl, it is in ssl_error or so.

Sometimes the script *must* be named whatever.cgi, .pl extennsion will not run. Depends on server setup.

When you use the cli, the script is running as the invokee (unless with sudo, but that's kinda outta scope). That means if you log in as joe, and you run sue.pl, sue.pl runs with joe's permissions.

But when you call this via a browser... aha.. it may not be running as 'joe', it may be running as 'apache' or "sue". And apache and "sue" may not have the permissions to do what your script is trying to do- maybe even run!

Where is the script? It may have to be in cgi-bin, some servers are configured to demand that. If so, make sure this is there.
You can make a cgi-bin dir alongside public_html(like) and then make a soft link in public_html/cgi-bin to that one.. that may work it in such case.


In reply to Re: CGI script returns no values in browser but is ok on command line? by leocharre
in thread CGI script returns no values in browser but is ok on command line? by gudmo

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.