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

does not write to file anymore

by BzBeauty (Sexton)
on Nov 05, 2004 at 00:12 UTC ( #405342=perlquestion: print w/replies, xml ) Need Help??

BzBeauty has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have this site running that writes to a flat file. It's worked every single day and then all of a sudden seemed to stop working. No errors are thrown but the flat file is empty. I checked the permissions on the flat file even set the file to 777. I checked the Document_root, even had it create and write to a new file. It created a new file all right but the contents was blank.

Any ideas why it's not writing to the file? Here's the code...
open (PAGE,">$mainpath") || &Error_File("$mainpath"); print PAGE "testing"; close (PAGE);

Replies are listed 'Best First'.
Re: does not write to file anymore
by tachyon (Chancellor) on Nov 05, 2004 at 00:22 UTC

    Nothing ever just suddenly stops, there is always a reason. Could your disk be full? Are you writing to a file but $mainpath does not point where you think? Is mainpath a relative path or a full path. Why don't you see what Perl reckons:

    use Cwd; open F, ">$mainpath" or die "Open $!\n"; print F "Testing\n" or die "Print $!\n"; close F or die "Close $!\n"; print "CWD: ", cwd(), "\n$mainpath\n"; open F, $mainpath; print while <F>; close F;

    cheers

    tachyon

      Ok,

      I put the code in

      close F or die "Close $!\n";

      And it died at this point. How do I check the $! ???

      thanks

        That statement should print whatever is in $! and $! should be set if the close fails. Have you checked to see if your disk is full? On *nix type df. If you have disk space try (on the command line)

        echo testing > somefile cat somefile

        Does that work?

        As well as checking disk free with df check quotas with quota

        quota your_username quota nobody quota apache
Re: does not write to file anymore
by diotalevi (Canon) on Nov 05, 2004 at 00:16 UTC
    print() and close() are also system calls just like open(). Put an or &ErrorFile( $mainpath ) on them too. You should be tracking $! as well.
Re: does not write to file anymore
by stonecolddevin (Parson) on Nov 05, 2004 at 00:17 UTC
    Is your ISP running apache?
    If so, try setting suEXEC (when you go to chmod the file) to 4, so it will look like 4777.
    I had a problem like this, and that seemed to work.
    meh.
Re: does not write to file anymore
by csuhockey3 (Curate) on Nov 05, 2004 at 00:23 UTC
    I had a bit of a flatFile problem last week and got plenty of great feedback. I think you will find some good troubleshooting ideas there.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://405342]
Approved by atcroft
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2019-12-13 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?