Re: File Can Not Write
by cog (Parson) on May 06, 2005 at 22:08 UTC
|
Why can't I write this file
Does it open successfully? If not, what's the error? What's the output of your script?
In the error message (in case it doesn't open), I would include the name of the file (sometimes it might be a good hint as to what is going on).
And more importantly, why aren't you using strict? | [reply] |
|
|
Aloha,
I didn't mean for this to get posted without the explanation I had but when I hit update it published accidently. I am still trying to find the best way to paste my code. I've read where I have to use so it will look half way decent. I use BBEdit to write scripts. I get no error from the script not even the bottom line prints to the screen.
JWG
| [reply] |
|
|
I use BBEdit to write scripts.
Begin to use code tags instead :)
not even the bottom line prints to the screen
I don't get the full meaning of this sentence, but I understand that you don't see the "I was Here!" message, correct? If so, your program is exiting at the die statement, but you don't see it in the browser - go look in the logs. If you want error messages be displayed in the browser, use CGI::Carp:
use CGI::Carp qw(fatalsToBrowser);
Now all fatal messages (triggered by die) will be output to the browser as well as the log file.
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
| [reply] [d/l] [select] |
|
|
Then edit your original node...
| [reply] |
Re: File Can Not Write
by chas (Priest) on May 06, 2005 at 22:24 UTC
|
The file may have to exist already and be writable by anyone
for your open and write to succeed.
The path to the file may have to be the complete path relative to the web server main document directory.
chas | [reply] |
|
|
I can read the same files but I can not write to them (not even overwrite them).
| [reply] |
Re: File Can Not Write
by tlm (Prior) on May 06, 2005 at 22:28 UTC
|
If you are usingAt least with Apache on Linux, make the directory and the file must be world-writeable.
Update: My reply is an oversimplification. See frodo72's reply for a more complete and precise description of the permissions issue.
| [reply] |
|
|
I don't agree on that. The file must be writeable by the user which "runs" Apache (which varies from system to system, it could be "apache", "nobody" or whatever). This can happen in a lot of manners (e.g. file is owned by that user, and user-writeable; user is within file's group, and file is group writeable...), which doesn't necessarily imply world-writeability. In case the file doesn't exist yet, the above consideration applies to the directory.
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
| [reply] |
|
|
I will change to world writeable. I am using Apache on Mac OS 10.39
| [reply] |
Re: File Can Not Write
by the_slycer (Chaplain) on May 07, 2005 at 06:03 UTC
|
Well, there's very little information in your post but...
Are you checking the params at all? Looking at the above, perhaps the script isn't receiving any values in the params? If you enable warnings (use warnings) at the top of the script, it may give you further information..
What happens if you give it an explicit path for the filename instead of the ../..?
In particular, if $employee is undefined, the file may be created as simply ".txt" instead of the employee name.
General comments:
use warnings; use strict; they may seem like a pain, but you will save all kinds of headaches with incorrectly typed variables in the future.
Check your variables before using them.. if you're accepting the employee name as a param & then blindly using it, you're in for a world of hurt when someone adds something that shouldn't be there (an extra / & a .. comes to mind...).
| [reply] [d/l] |