I have a Perl script that prints multiple lines of output to screen. I need to capture those lines and either pipe them into a single piece of email ( /bin/mail ) or into a text file that I can send by /bin mail in another operation. Actually, I have already figured out the easy (dumb) way whereby I use a bash wrapper to do the mailing bit. Looks like,
#!/usr/bin/bash
source /nethome/zog/.bash_profile
cd /nethome/zog/bin/perl
/nethome/zog/bin/perl/find_free_space.pl > text.file
/bin/mail -s FreeSpace@NJ3 [email protected] < text.file
I want to be using Net::SMTP to do the smtp bit. The above is inelegant, to say the least.
I saw something like this:
open(MAIL, "| /bin/mail -s FreePorts me\@geemail.com") ||
die "mail failed: $!\n"; print MAIL "This is how it goes."
on stackoverflow but failed to redirect the STDOUT into mail. I'm using:
$complete_output .= "\n"; "|/bin/mail -s FreePorts zog\@geeemail.com" || die "mail failed: $!\n";
I'm not sure if you all need to see the Perl script in order to help, but it is on pastebin. Please let me know.