in reply to CGI script cannot create file.
# somewhere in the main part of the script use CGI qw/ fatalsToBrowser /; use CGI::Carp; ... sub WebPassWrite { ... mumble open PAS,"> hf" or die $!; #Always catch errors!!! }
You'll notice I've added the die $!; to your open statement. This eliminates some of the guesswork and worst case will emit to your servers's log files some form of error that you can use to determine what happened.
More commentary: Most web servers (Apache, IPlanet, whatever the hell Microsoft publishes these days) run CGI scripts as a restricted or trivial user. Some common userids under *nix that this happens as are as follows:
I am not a big fan of using relative paths when opening a file for writing. There exists a danger that you end up writing the file someplace you don't expect. For instance if you CGI script is running as yourself (rare occasion) but the current working directory the script is running at is somewhere you don't have write access your code is going to bomb.
Lastly... I'm not sure what you are trying to accomplish here. Writing passwords to a file has attendant dangers. Make sure the permission bits on the file are restrictive enough to prevent prying eyes for looking at it. Having a CGI script write those passwords is an even worse idea. Gives hackers something to shoot at.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CGI script cannot create file.
by Anonymous Monk on Dec 20, 2012 at 03:02 UTC | |
by blue_cowdawg (Monsignor) on Dec 21, 2012 at 13:24 UTC |