The perl scipts on my RedHat FC4 box are behaving strangely (as far as I can tell). The scripts error when run via the browser: Can't open perl script "/dir/script.pl": Permission denied

I've ensured that the permissions are correct (to the point of recursively chmodding everything in /var/www to world read and execute).

I created a small Hello World script (double checking that the shebang line was correct) in the cgi-bin directory - with the same problems. I ran the HW script from the command line with the syntax perl helloworld.pl (which worked) and then ran it with the syntax ./helloworld.pl (which did not work). The second syntax had an effect as if I just hit the return key - it did nothing.

I then copied the script to my home directory and tried both syntaxes - they both worked. I then created helloworld2.pl and tried to replicate this behaviour, but, sadly, this script did not work using the second syntax from my home directory.

I'm stumped. I've pasted my experience below.

~>cd /var/www/cgi-bin /var/www/cgi-bin>cat helloworld.pl #!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello World\n"; /var/www/cgi-bin>which perl /usr/bin/perl /var/www/cgi-bin>perl helloworld.pl Content-type: text/html Hello World /var/www/cgi-bin>./helloworld.pl /var/www/cgi-bin>cp helloworld.pl ~ /var/www/cgi-bin>cd ~>perl helloworld.pl Content-type: text/html Hello World ~>./helloworld.pl Content-type: text/html Hello World ~>cd /var/www/cgi-bin /var/www/cgi-bin>cat helloworld2.pl #!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello World2\n"; /var/www/cgi-bin>perl helloworld2.pl Content-type: text/html Hello World2 /var/www/cgi-bin>./helloworld2.pl /var/www/cgi-bin>cp helloworld2.pl ~ /var/www/cgi-bin>cd ~>perl helloworld2.pl Content-type: text/html Hello World2 ~>./helloworld2.pl ~>diff helloworld.pl helloworld2.pl ~>

EDIT 1: Specifically, all the scripts *are* executable.

EDIT2: ls -l /usr/bin/perl `which perl` -rwxr-xr-x 2 root root 15660 Mar 13 2006 /usr/bin/perl -rwxr-xr-x 2 root root 15660 Mar 13 2006 /usr/bin/perl

-=( Graq )=-


In reply to Scripts (mostly) doing nothing when run from command line. by graq

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.