[Za-pm] no STDIN

Spike spikeh at mweb.co.za
Wed Dec 22 06:42:32 CST 2004


Hi All
I have a small perl script called "male" which is used in much the same 
way, with similar options as "mail".
That is you can do things like echo"boo" | mail spike at mweb.com
But male allows a few extra options that I find useful like you can set the 
reply address and Cc etc from the Command line too. i.e cat myfile.txt | 
male -c cc at mweb.com -r sender at spam.com spike at mweb.com

The most useful bit being the -a that allows me to send a file as an 
attachment. Now this is where my problem is. It all works fine as long as 
I  cat myfile | male ....  or echo"my message to you" | male ......

But often I don't want to send a message body - i just want to send an 
attached file.    male -a myfile spike at mweb.com

The problem is that it just hangs waiting for something on STDIN.

I capture the STDIN with

while (<STDIN>)
{
         $body .= $_;
}

In have also tried

@body = <STDIN>;

and

if(<STDIN>)

but as soon as we get a <STDIN> it waits for one!

Anyone have an idea on how I can get the script to realize when there will 
be no STDIN - (other than another switch on the Command line)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20041222/6564fb17/attachment.htm


More information about the Za-pm mailing list