| | |
Automated FTP Sendmail Attempt
Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 2
Reputation:
Solved Threads: 0
Got a quick question.
I have created a simple automated FTP script that goes out and snags my file, then reads it and drops it into an array. Following that, I want for the script to send a mail out with the contents of array (the recipient and subject are static).
A few things I want to point out:
a) Intermediate at perl, so my code may not be the cleanest.
b) I am using postfix for MTA and it is functioning properly.
I have tried using both open(MAIL) and open(SENDMAIL) but when using these, I get a mail in my Dead Mail box on my mail server showing that the TO was not passed correctly, most likely due to my error...
Script below (MAIL section omitted, as its not working)
[code]
#!/usr/bin/perl
$dir = "autorpt";
$file = "AUTOPRT.log";
use Net::FTP;
my $host="*********";
$ftp=Net::FTP->new($host,Timeout=>340) or die "Can't connect";
$ftp->login("*****","*****") or die "Can't Login";
$ftp->cwd("$dir") or die "Can't CD";
$ftp->get("$file") or die "Can't Get";
$ftp->quit;
open(FILE, "$file") or die"Can't Open";
@msg = <FILE>;
close(FILE);
[code]
Any help or insight would be greatly appreciated.
Thanks,
William
I have created a simple automated FTP script that goes out and snags my file, then reads it and drops it into an array. Following that, I want for the script to send a mail out with the contents of array (the recipient and subject are static).
A few things I want to point out:
a) Intermediate at perl, so my code may not be the cleanest.
b) I am using postfix for MTA and it is functioning properly.
I have tried using both open(MAIL) and open(SENDMAIL) but when using these, I get a mail in my Dead Mail box on my mail server showing that the TO was not passed correctly, most likely due to my error...
Script below (MAIL section omitted, as its not working)
[code]
#!/usr/bin/perl
$dir = "autorpt";
$file = "AUTOPRT.log";
use Net::FTP;
my $host="*********";
$ftp=Net::FTP->new($host,Timeout=>340) or die "Can't connect";
$ftp->login("*****","*****") or die "Can't Login";
$ftp->cwd("$dir") or die "Can't CD";
$ftp->get("$file") or die "Can't Get";
$ftp->quit;
open(FILE, "$file") or die"Can't Open";
@msg = <FILE>;
close(FILE);
[code]
Any help or insight would be greatly appreciated.
Thanks,
William
Last edited by wdean; Oct 24th, 2006 at 2:08 pm. Reason: die("Can't Open"); to die"Can't Open";
![]() |
Similar Threads
- Read and parse and xml file from an ftp server (PHP)
- URGENT: FTP Client / Server using RMI (Java)
- Hijackthis report, I just don't know (Viruses, Spyware and other Nasties)
- using sendmail from home machine (Shell Scripting)
- RedHat Network Server (*nix Hardware Configuration)
- My PC won't start...please help. (Windows NT / 2000 / XP)
- Tek's FTP (Networking Hardware Configuration)
Other Threads in the Perl Forum
- Previous Thread: Updating a file: setting the offset
- Next Thread: Calling one Perl script from another - HELP!!!
| Thread Tools | Search this Thread |





