Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Comment on

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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (15)
    As of 2018-05-28 09:04 GMT
    Find Nodes?
      Voting Booth?