in reply to Re^6: Failed System/Exec Call under Right Permission with CGI
in thread Failed System/Exec Call under Right Permission with CGI

"So sorry to have to comeback to you again McDarren. I'll try not to trouble you again after this.... "

You should never feel like you need to apologise for asking advice. That's what SOPW is for :)

Anyway, this is almost certainly a permissions problem. You need to ensure that the user the webserver runs as has appropriate permission to write to the directory involved.

Here is an example that I've tested, and works (with appropriate permissions set):

never.cgi

#!/usr/bin/perl -w use strict; use CGI qw/:standard/; use Cwd; print header(); my $dir = getcwd; my $param1 = qq(hello, cruel world. A test; for \\\$neversaint.); my @args = ( "$dir/never1.pl", $param1, "$dir/test/never.out" ); system(@args) == 0 or die "Code does not work:$!"; exit;
..and the script that is called:
#!/usr/bin/perl -w use strict; my $text = $ARGV[0]; my $outfile = $ARGV[1]; open OUT, ">", $outfile or die "$0 : failed to open output file $outfile:$!\n"; print OUT "THIS IS YOUR INPUT TEXT: $text\n"; close OUT; exit 0;
and after loading the cgi script in my web browser:
cat test/never.out THIS IS YOUR INPUT TEXT: hello, cruel world. A test; for \$neversaint +.

Cheers,
Darren

Replies are listed 'Best First'.
Re^8: Failed System/Exec Call under Right Permission with CGI
by neversaint (Deacon) on Jul 20, 2006 at 05:57 UTC
    McDarren,

    Did you try running "never.cgi" from the browser?
    I tried running "never.cgi" from linux command line. It works.

    But not when I execute from the browser:

    http://mys_server.com/~myname/MyTest/cgi-bin/never.cgi
    BTW, I also placed "never.pl" under cgi-bin/.

    Following my msg to you. What's the permission like for your test/ directory?
    I had "chmod 755" for my results/ directory. Is it right?

    And where is the location of your test/ directory ? under this?
    /home/yourname/public_html/somedir/test/


    ---
    neversaint and everlastingly indebted.......
      This should tell you what permissions cgi scripts run as:
      ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell,$expire) = + getpwuid($>); print "Running as user $name (uid $uid)\n";
      It is fairly common for cgi applications to run under a restricted user account.

        I usually do:

        print "$< - $> - $( - $)\n";

        --
        David Serrano