email after job completes

Sort:
You are not authorized to post a reply.
Author
Messages
Chesca
Veteran Member
Posts: 490
Veteran Member

    My users told me that they receive an email whenever the job they run completes, I am looking at the script and can't figure out which line of code does that. I see it commented it out. Could somebody please take a look and let me know if I am missing anything?

    #!/usr/bin/perl -w

     use Env;

     use Net::FTP;

     $PERL_SID = $ENV{'PERL_SID'};

     $PERL_PDL = $ENV{'PERL_PDL'};

     unless(defined($PERL_SID)){&F;exit(1);}

     $PATH = "/usr/local/bin:$ENV{'PATH'}";

     $SENDER = $ENV{'USER'};

     $FILE = "myfile.csv";

     #$MAILTO = "xxxystems\@mail.org";

     chdir("/$PERL_SID/law/$PERL_PDL/work/CSV") || &F;

     @Outbound = ("$FILE");

     if ($ftp = Net::FTP->new("variance.company.org", Timeout=>999)) {

         $ftp -> login("xxx", xxxxxxxx');

         $ftp -> binary;

         $ftp -> cwd("/pub/incoming");

         foreach $File (@Outbound) {

            if ( ! -e "$File" ) { &F ; next ; }

            $ftp -> put("$File") || ( &F ) ;

         }

         $ftp -> quit; }

     else { &F; }

     system("cp $FILE $FILE.bak")==0 || &F;

     system("cat $FILE.bak | /usr/local/rpci/bin/unix2dos | uuencode $FILE.bak $FILE.csv | mailx -m -s 'file sent File' $SENDER")==0 && un

     exit;

     sub F {

         my ($M1,$M2,$M3) = caller;

         open (MAIL, "|/usr/lib/sendmail $SENDER") || die;

         print MAIL "Subject: Transfer failure\n\n";

         print MAIL "\nTransfer Failed: \n";

         print MAIL "It appears that your myfile.csv transfer \n";

         print MAIL "has failed \n\n";

         print MAIL "Failure message was:\n";

         print MAIL "$M1 - $M2 - linenumber: $M3\n";

         close (MAIL);

     }

     

    John Henley
    Senior Member
    Posts: 3348
    Senior Member
      system("cat $FILE.bak | /usr/local/rpci/bin/unix2dos | uuencode $FILE.bak $FILE.csv | mailx -m -s 'P&AA Inc File' $SENDER")==0 && un
      the $SENDER variable is misnamed...that is the recipient...looks like the value is from the USER env variable.
      Thanks for using the LawsonGuru.com forums!
      John
      Chesca
      Veteran Member
      Posts: 490
      Veteran Member
        Thanks a lot, John!
        You are not authorized to post a reply.