Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
      My suspicion is that the script does not have permissions to create files

# 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:

  • httpd (trivial user)
  • apache (trivial user)
  • nobody (restricted user)
  • nofiles <restricted users)
In some rare cases (hosting providers for instance) run either a web instance with the userid of the "owner" or CGI as the "owner" or both. In that event make sure your are writing the file to someplace under your home directory.

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.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

In reply to Re: CGI script cannot create file. by blue_cowdawg
in thread CGI script cannot create file. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found