File not being written to and no errors?

From: Arichmond (arichmond_at_snap.org)
Date: 07/29/04

  • Next message: Bob Showalter: "RE: Modifying @INC"
    Date: Thu, 29 Jul 2004 08:18:22 -0400
    To: <beginners@perl.org>
    
    
    

    I have a file I am trying to read and write to, it's obviously opening
    it ie.. No errors but not writing to it.

     Since no errors are being produced I can't figure out why?

    In short I am reading the file to see if I previously sent an email
    concerning a "name" and if I have then don't send another email, if I
    have not then do send an email.

    I am pretty sure of the logic as I receive the email, but it is not
    writing the new "name" to the file.

     

    Above and below, I am opening another file read/write in the same way
    and it works just fine. Any suggestions on how to check what's going on?
    I am using strict, warnings and diagnostics and everything appears to be
    clear.

     

    File:

    -rwxrwxrwx 1 root root 11 Jul 28 08:59 sent

     

    1)

    #!/usr/bin/perl

    use strict;

    use warnings;

    use diagnostics;

    use Net::NBName;

    use Fcntl ':flock';

    use Net::Ping::External qw(ping);

    our ($d,$m,$y)=(localtime(time-86400))[3..5];$m+=1;$y+=1900;

    ...

    ...

    2)

    our $done='/var/scripts/snmp/sent';

    our %sent=();

    ...

    ...

    3)

    open (DONE,"+>>$done") or die "Cannot open file: $!";

            flock (DONE, 1);

            foreach (<DONE>){

            chomp($_);

            $sent{$_}="";

            }

    ....

    ...

    if (exists $sent{$mapn}){

                    }else{

    ...

    ...

    4)

    }elsif($ns && ($ns->as_string =~ /^(.*)\s*\<00\>/i)) {

                                                    push @mailbody, "AN
    UNAUTHORIZED Device Was Detected\n";

                                                    push @mailbody,
    "$maprh,$maprb,$maprp,$maprm,$mapip,$1\n";

                                                    print DONE "$1\n";

     

    ...

    ...

    5)

    ...

    flock(DONE, 8);

    close(DONE);

    ...

     

     

     

    Thanks,

    Rich

     


  • Next message: Bob Showalter: "RE: Modifying @INC"

    Relevant Pages

    • Re: fopen() question.
      ... note that opening a file for update does not create ... so if you want to open only an existing file for writing you ... opening it again with "r+" if you really do want update mode). ... platform-dependant anyway, you may as well write platform-dependant ...
      (comp.lang.c)
    • Re: module: zipfile.writestr - line endings issue
      ... Maybe the issue lies with this way ) of writing the ... The problem is with how you are opening the file. ... dfile = file ... Python documentation seem to recommend using open. ...
      (comp.lang.python)
    • Re: lseek: Value too large for defined data type
      ... printf("File opening success\n"); ... spacecriter (Bill C) wrote: ... writing 100MB of data consecutively 10240 times. ... Value too large for defined data type error. ...
      (comp.os.linux.development.system)
    • Re: lseek: Value too large for defined data type
      ... printf("File opening success\n"); ... spacecriter (Bill C) wrote: ... writing 100MB of data consecutively 10240 times. ... Value too large for defined data type error. ...
      (comp.os.linux.development.system)
    • Re: while loop problem
      ... Purl Gurl wrote: ... Opening File_1 For Writing ... Now Closing File_1 ...
      (perl.beginners)