Hi monks,
I'm trying to write a cgi script to take data from a text input on an HTML form and (after a bit of manipulation) write it as a text file. After several hours of surfing and experimenting I don't think I'm getting any closer.
When I try to code it as per this mode it looks like this:
#Save the story to file open STORY,">$storyfile"|| die "Could not write to $filename\n"; printf STORY $story; close (STORY);
$storyfile is the full path and filename for the new file, $filename is the filename on its own and $story is the content for the file. All of these are defined earlier in the script.
I end up with this error:
Insecure dependency in open while running with -T switch at /usr/lib/cgi-bin/upload.cgi line 33.
Line 33 is the second line posted above. I tried to sort out what this means and found several places that said this implied a permissions problem. I made sure everyone could write to the directory but still get the same result.
When I follow the advice in this thread my code looks like this:
open(STORY,$storyfile)|| die "Could not write to $filename\n"; printf STORY $story; close (STORY);
and I get this:
Could not write to 00041616l_k_j
00041616l_k_j is the filename less its suffix. I am having no problem opening similar files in the same directory for reading so I'm thinking I have missed out a step in the creation of a new file. Can anyone suggest what I may be doing wrong here?
Thanks for your help.

In reply to Having trouble creating a text file by greymoose

Title:
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, details, 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, summary, 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.