in reply to Re: CGI System Commands
in thread CGI System Commands

Thanks
Here's what Im trying to do
my @arr=`dir $path /b`;
The script runs smoothly from the path c:\....apache\cgi-bin from the command prompt.
When the script is called from a web page, it gives an error.THe cgi looks like:
#!c:\perl\bin\perl use strict; use CGI qw(:standard); my $labelpath="\\\\<some computer name or ip address>\\<a shared folde +r (permissions - all)>"; my @arr=`dir $labelpath /b`; print header; print start_html('Thank you'); print <<EOF; <head> <title>Test</title> </head> <body text="#rrggbb" bgcolor="#D7DFEE"> </body> Hello $arr[0] <br> $arr[1]...etc. EOF print end_html;


we're born with our eyes closed and our mouths wide open, and we spend our entire life trying to rectify that mistake of nature. - anonymous.

Replies are listed 'Best First'.
Re: Re: Re: CGI System Commands
by BrowserUk (Patriarch) on Aug 05, 2003 at 11:06 UTC

    When you run the script from the command line, is runs with whatever privaleges your logon id has. If you can dir the target share, then the program can.

    When the script is invoke as a cgi, it only has whatever privaleges the webserver account has. These usually defualt to very low privaleges for safety.

    Find out what account the web server runs as--ask your SysAdmin or ISP if you don't know how to find this information yourself--and then logon as that account and try your dir from the commandline. It almost certainly will give you "Access denied".

    To summarise:

    • This is nothing to do with perl.
    • Nothing to do with your code.
    • No amount of changing to your code will fix the problem.

    You need to give the webserver account the correct permissions, or talk to someone that has the authority to do this on your behalf.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.