Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Stupid newbie question - perl/cgi

by mt2k (Hermit)
on Apr 03, 2002 at 01:35 UTC ( [id://156199]=note: print w/replies, xml ) Need Help??


in reply to perl/cgi question: script works from unix command line, but not web page

Ahem, I think the answer is probably VERY simple. If you say it works on the command line and when using it as a CGI script it prints out to the browser correctly, but the data file is not being saved the browser, then the answer is indeed simple: your script does not have permission to write the file.

The solution? try chmoding the cgi script 777 and then run it. It might work then, as some server configurations give your perl script the same file access permissions as the permissions of the script you are running. Otherwise, either you (assuming you are the server administrator) or the server administration will have to set up the Web Server up differently.

For the problem of system "main.cgi"; not working, use system "perl main.cgi"; instead, since main.cgi probably does not have execute permissions.

Replies are listed 'Best First'.
Re: Re: Stupid newbie question - perl/cgi
by Juerd (Abbot) on Apr 03, 2002 at 05:49 UTC

    The solution? try chmoding the cgi script 777 and then run it.

    Leaving the script at 0777 is very foolish. Do try this solution, but if it works, immediately re-set the file permissions to something harmless like 0744, and learn about unix permissions before you set it to something that works again.

    The number 0777 may not mean a thing to you, so here's a small explanation: it allows everyone to run the file, read the file or change the file. When someone else changes the file, and you execute it, there might be disastrous results.

    mt2k, please do never recommend 0777 as a mode for ANYTHING, as it's insecure. For executable scripts, 0755 should always be enough: that lets only yourself change it, but everyone can read or execute it.

    U28geW91IGNhbiBhbGwgcm90MTMgY
    W5kIHBhY2soKS4gQnV0IGRvIHlvdS
    ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
    geW91IHNlZSBpdD8gIC0tIEp1ZXJk
    

      Aha, there is a reason, however, why I suggested 0777 as the permission for scripts.
      The server I am working on is setup in a bad way.
      Whatever permissions are set for the script are the same permissions my scripts are granted for files.

      If I chmod the script 0755, then my script can read and execute files, but it cannot write to files!!
      If I chmod it to 0777 it can read, execute, and write to/from files.

      This is a very strange behaviour, but it is how the server I am on works. So to be able to write to files, I HAVE to chmod my scripts to 0777.

        So to be able to write to files, I HAVE to chmod my scripts to 0777.

        I would have refused to work with such crap. If any other user on the machine, and badly set up machines tend to have a lot of users, adds system qw(rm -rf), $ENV{HOME}; to your script, you will be fried on its first run.

        U28geW91IGNhbiBhbGwgcm90MTMgY
        W5kIHBhY2soKS4gQnV0IGRvIHlvdS
        ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
        geW91IHNlZSBpdD8gIC0tIEp1ZXJk
        

Re: Re: Stupid newbie question - perl/cgi
by geoffhanna (Initiate) on Apr 03, 2002 at 03:44 UTC
    It didn't occur to me that my ISP webserver may have settings that restrict what is available for public access. It should have, IIS certainly does.

    Now I'm curious. I'll ask my ISP.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://156199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-29 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found