Forum Moderators: coopster & phranque

Message Too Old, No Replies

executing shell commands

         

adwyer

10:16 am on Apr 23, 2005 (gmt 0)

10+ Year Member



I am just trying to write a quick bit of cgi code so i can download things in my cvs repository without having to login the my account. this is the code i have but i'm not having any luck. the command works when i actually type it but not when i run the page.

#!/usr/local/bin/perl -w
print "Content-type: text/html\n\n";
$ret = `cvs -d /public/directory..../cvs/ export -r HEAD analysis`;
print "$ret<br>";

thanks

rocknbil

4:36 pm on Apr 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could TRY
$ret = system("cvs -d /public/directory..../cvs/ export -r HEAD analysis");

timster

6:21 pm on Apr 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



system("cvs -d /public/directory..../cvs/ export -r HEAD analysis");

I don't think that's the problem. The perl.com pages say:

The return value [ of system ] is the exit status of the program as returned by the wait() call. To get the actual exit value divide by 256. See also exec. This is NOT what you want to use to capture the output from a command, for that you should use merely backticks or qx//, as described in `STRING`.

http://www.perl.com/doc/manual/html/pod/perlfunc/system.html [perl.com]

If the Perl script runs fine in Terminal but not in CGI, I'd check whether the "CGI user" has access to read the directory in question.

Edit: Added link to Perl.com page

adwyer

8:19 am on Apr 29, 2005 (gmt 0)

10+ Year Member



thanks very much. ofcourse! i totally forgot about the permissions of the directory. hehe stupid me :)