in reply to system call in cgi/perl script on linux

Did you check your web server log? Does it have any errors?

Could it be a permission problem? You need to remember that your cgi program is run under a different user than yourself (the httpd or apache user if you are on a unix machine). The permission problem is the one that usually bites. One way to test this is to setuid to the web server user, and run the cgi script again.

There are other possible causes too, but check the permission first.

  • Comment on Re: system call in cgi/perl script on linux

Replies are listed 'Best First'.
Re^2: system call in cgi/perl script on linux
by Anonymous Monk on Jun 17, 2004 at 14:33 UTC

    Thank you. I'm so confused.

    I think the problem is because the program that system() is calling is a bash script, so yes, the permissions and directories are all messed up. I'll probably have to do it by trial and error...

    I was wondering if you could please tell me that if the cgi program (or rather the bash script the cgi program is calling) has to write a file, what permissions do I have to set the directory (where the file will be put) to?

    Thanks very much,
    roseberry

      Step 1 - Find out the user name and group that the web server is running under.

      ps -ef | grep httpd # this will show you the user id of the web server

      Step 2 - Find out the permission of the directories and files you are trying to read from and write to.

      ls -al /my/path

      Step 3 - Change the group of your directory and files to the httpd user group, and set group read/execute permission on the directories and files.

      # httpd group (you can find out from the /etc/password # and /etc/group files chgrp -R httpd /my/path chmod -R g+rx /my/path

      Step 4 - Well, test again.

      su - httpd # set uid to httpd user, assuming that you are the # root user and no password is required # run your cgi script from the command line. # you don't need to use a browser to test the cgi script.

      By the way, you do have root access to the system, don't you?

        Thank you for the hints. :)