Operating System - HP-UX
1753964 Members
7034 Online
108811 Solutions
New Discussion юеВ

help converting perl script output to korn

 
Tracy Force
Occasional Contributor

help converting perl script output to korn

Can anyone help or point me in the right direction for converting output of a perl script into korn so that it can be emailed/ipaged to a list of addresses?. thanks
4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: help converting perl script output to korn

These links may help.

http://omaha.pm.org/emails/2003/msg00083.html

http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q5.19.html

Also note that I've written perl scripts that read email listes and queue up outbound messages.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Pete Randall
Outstanding Contributor

Re: help converting perl script output to korn

Tracy,

What sort of output are you getting from your perl script? To my way of thinking, it should be some form of text output that could be just piped to mailx.


Pete


Pete
Pete Randall
Outstanding Contributor

Re: help converting perl script output to korn

To expand on that thought, would something like this work?

perl.script > /tmp/perlscript.out
mailx -s "perl.script" Tracy_Force@yourdoman.com < /tmp/perlscript.out


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: help converting perl script output to korn

That the output is Perl doesn't matter at all. It could be from a shell script, a C program, or from Santa Claus. There are basically 2 ways to handle your situation: aliases or a loop. You could create a mail alias which includes those users in your list so that instead of using one user, you would mail to the alias and the mail command would handle the rest. This is actually the better approach because it's so easy to add/modify the aliases. Man aliases for details.

Here's the loop method:

#!/usr/bin/ksh # you should use /usr/bin/sh (POSIX)

TDIR=${TMPDIR:-/var/tmp}
M1=${TDIR}/X${$}_1.txt

# capture Perl output in temp file
myperl.pl > ${M1}

USERS="mickey@disney.com bugs@warnerbros.com clark_kent@dellcomics.com"

for U in USERS
do
cat ${M1} | mailx -s "My subject" ${U}
done
rm -f ${M1}

Note: The mailx command allows multiple addresses so you could specify more than 1 BUT the total length of addresses cannot exceed 1024 characters so the loop is safer.

It would be much simpler to do this:

myperl.pl | mailx -s "My Subject" myalias

"myalias" would then handle everything for you.


If it ain't broke, I can fix that.