in reply to Re^2: need help with FTP script
in thread need help with FTP script

You're missing a semicolon on the previous line.

We're not really tightening our belts, it just feels that way because we're getting fatter.

Replies are listed 'Best First'.
Re^4: need help with FTP script
by cc (Beadle) on Jun 12, 2004 at 09:34 UTC
    thanks Roy

    it works perfectly now !

    greetings
    cc
Re^4: need help with FTP script
by cc (Beadle) on Jun 15, 2004 at 21:58 UTC
    hi Roy

    I have a question.
    I try to send an error mail, when the transfer was not completed, but I don't get any mails.
    Path to sendmail and recipient address are correct:
    ...................................................................... +... # check if the first file is still there my $found = grep /\Q$new\E/, $ftp->ls; if ($found) { die "The file is still there !\n" and next; { # send mail if transfer not completed open(MAIL, "|/usr/sbin/sendmail -t") || die "Cant send mail. Reason: +$!"; print MAIL "from:$sender\n"; print MAIL "to:$recipient\n"; print MAIL "subject: transfer was not completed !\n"; print MAIL "transfer of second file failed ! \n"; print MAIL "Time: ", scalar localtime, "\n"; close(MAIL); } } #quit FTP when finished $ftp->quit; ...................................................................... +...
    and I don't get any errors.

    greetings
    cc
      You need to put the recipient on the command line, as well as in the headers:
      open(MAIL, "|/usr/sbin/sendmail -t $recipient") || die "Cant send mail +. Reason: $!";
      Sendmail determines where the mail is going from the command line.

      We're not really tightening our belts, it just feels that way because we're getting fatter.
        hi Roy

        I've changed but still doesn't work.
        I think without -t, because:
        " sendmail: fatal: cannot handle command-line recipients with -t "

        I don't understand, if I try only this simply mail script then works well and I get mails:
        #!/usr/bin/perl -w my $recipient = "xxx\@mydomain.net"; my $sender = "yyy\@mydomain.net"; open(MAIL, "|/usr/sbin/sendmail -t") || die "Cant send mail. Reason: $ +!"; print MAIL "from:$sender\n"; print MAIL "to:$recipient\n"; print MAIL "subject: test mail\n"; print MAIL "Time: ", scalar localtime, "\n"; close(MAIL);
        I think the problem is the combination with the transfer script.

        kind regards
        cc