Re: cgi script unable to create files on server.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jamal, listen.

- all your scripts can create a file when you run them from the command-line. Yes ? - all your scripts get an error when they try to create a file when they are being run by Apache. Yes ? - then it means that there is a difference, between when you run them from the command-line, and when Apache runs them. Yes ? - one of these differences is that when you run them from the command-line, you run them under /your/ login user-id. But when Apache is running them, it is running them under /Apache's/ user-id. Yes ? - there may be other differences, like the fact that when you run them from the command-line, you run them from whatever directory you are currently cd'ed into. While, when they run under Apache, under what directory are they ? and where are they trying to create that file ? - if a program cannot create a file and/or write to a file, there is a reason. But the possible reasons are many : it may not have write permission to the directory where it is trying to create a file, or the directory may not exist, or the filename may be invalid, or there may not be any space left on the disk, or another file may already exist with the same name and cannot be overwritten, or a dozen other possible reasons.

So please, stop waisting more time looking for wrong explanations.
Make your script say exactly why it cannot create the file, and that may give you a clue to what is happening. A useful error message would be like : "Cannot create file [full path]. OS error code = xxxx; OS error message = xxxxxxxxxxxxx" (you may even want to print the date, time, current user-id, and current directory)

André



m jamal wrote:
its not just this script any script trying to create a file gives the error.it works nicely up to point when no file has to be created.when it reaches the point it has to create file it gives the error which i have specified in cerr.there is no problem of permissions.

--- On Sun, 4/12/09, André Warnier <aw@xxxxxxxxxx> wrote:

From: André Warnier <aw@xxxxxxxxxx>
Subject: Re:  cgi script unable to create files on server.
To: "m jamal" <mjamal_nasir@xxxxxxxxx>, users@xxxxxxxxxxxxxxxx
Date: Sunday, April 12, 2009, 5:14 PM

Hi jamal.

Please keep responding to the list, not to me personally.

I cannot tell you for Vista.
For XP it would be like this :
Assuming that you are running Apache as a Service :
Right-click on the "My Computer" icon, choose "Manage".
In the Window that appears, find "Services" and click on it.
In the list on the right, you should see "Apache ...".
Right-click on that.
This will give you a window with several tabs. One of them is named "Logon as...". That is where it is marked under which user-id Apache is starting. By default, it is probably set to "Local System". That is a special user-id which can do many things on the local system, but has for example no access to network resources.
Anyway, that is the user-id under which Apache is running.

Before you go changing this however, please check what your script is really trying to do, and why it is getting an error. In other words, make your error message (in the script) more descriptive :
- what is the file it is trying to open (full path)
- what error is it getting when trying to open the file (permission, file not found, directory not found,.. ?)


m jamal wrote:
OS is Windows Vista.How can i give that user id permission.The problem occurs only when apache runs the script.general c++ programs are able to create files.

--- On Sun, 4/12/09, André Warnier <aw@xxxxxxxxxx> wrote:

From: André Warnier <aw@xxxxxxxxxx>
Subject: Re:  cgi script unable to create files on server.
To: "m jamal" <mjamal_nasir@xxxxxxxxx>
Date: Sunday, April 12, 2009, 4:53 PM

m jamal wrote:
It says "could not open database".This is same error message which i have coded my script to show when it fails to open file.

Isn't that an amazing coincidence ?
;-)
So, it looks like it's not Apache having a problem, it is your script.
(Tip : whatever your script write to STDERR, will appear in the Apache error log.)
Another tip : when Apache runs your script, it does so under the user-id under which Apache itself runs.
You have not told us under which OS this all happens, but if it is Unix/Linux, try a "ps" command to see which user that is.
Does that user-id have the permissions to open the database ?
You may also want to make your script print a more descriptive error, such as why it cannot open the database.



--- On Sun, 4/12/09, André Warnier <aw@xxxxxxxxxx> wrote:

From: André Warnier <aw@xxxxxxxxxx>
Subject: Re:  cgi script unable to create files on server.
To: users@xxxxxxxxxxxxxxxx
Date: Sunday, April 12, 2009, 4:09 PM

m jamal wrote:
I am new to apache.The problem is that when i run a cgi script written in c++,all scripts run fine except those which create a file on server computer.For example i have written a script that creates a file to store user info.It runs fine.It collects info but when it tries to create a file to store that info apache  gives an internal server error.Please help how to solve this problem.I have wasted lot of time but unable to find any solution.I am using apache v2.2.11.

What does the Apache error log file say ?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx













---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux