Operating System - HP-UX
1752815 Members
6300 Online
108789 Solutions
New Discussion юеВ

Re: sending text from file via e mail

 
bob the spod
Occasional Advisor

sending text from file via e mail

I have a file which gets stuff written in it every now and then... what would be the best approach to get that data sent to my e-mail account.

I will try to work it into a crontab if thats possible too.

 

 

P.S.This thread has been moved from HP-UX>Databases  to HP-UX > languages-HP Forums Moderator

you make me feel like dancing (gonna dance the night away!)
10 REPLIES 10
Jeff Schussele
Honored Contributor

Re: sending text from file via e mail

Hi Bob,

Couple of ways.

1) If you want the data in the body of the msg

cat filename | mailx -s "Your Subject Here" user@company.com

2) If you want it as an attachment

uuencode filename filname.out | mailx -s "Subject line" user@company.com

HTH,
Jeff

P.S. What's a spod?
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
John Meissner
Esteemed Contributor

Re: sending text from file via e mail

you can put an entry in crontab to point to a script like this one:

cat file | mailx -s "filename" -r return@sender send_to@name

also you can:
mailx -s "filename" -r return@sender send_to@name
< file
All paths lead to destiny
Zafar A. Mohammed_1
Trusted Contributor

Re: sending text from file via e mail

Its very easy, even if you want in cron also.

tdate=`date +%m%d%y`
cp bob bob${tdate}

uuencode bob${tdate} bobfile | mailx -m -s "Subject" bob@bob.com


Put this file into your crontab

Thanks
Zafar
John Meissner
Esteemed Contributor

Re: sending text from file via e mail

just a note - my line wrapped on my last example... ignore that... it should all go on a single line
All paths lead to destiny
Dario_1
Trusted Contributor

Re: sending text from file via e mail

Hi:

You can write a script that check the file every so often and if newer then executed what Jeff posted. This way you won't get the file every time the script is executed.

Regards,

DR
bob the spod
Occasional Advisor

Re: sending text from file via e mail

Just to let you know I'm tinkering with your suggestions now - Jeff i'm trying yours first as it comes transverses into my brains code quite efficiently

in answer to your question... a 'spod' is another term for a person who's soul is gradually been sucked into a p.c. (via any spare usb port)
others like to use the word geek however i prefer the term spod - in my opinion it sounds more upper class!

Thanks for your suggestions

back to the box

Bob (the spod!)
you make me feel like dancing (gonna dance the night away!)
John Meissner
Esteemed Contributor

Re: sending text from file via e mail

bob - what if you don't have any spare USB ports? do I need to get a USB hub or will a firewire port work? :)

never heard of a spod before today.
All paths lead to destiny
Steven E. Protter
Exalted Contributor

Re: sending text from file via e mail

For more complex jobs' I'm attaching my production mailfile script. It works, and is a bit more flexible than mailx though I use both. As Mr. Scott once said, the right tool for the right job.

This job can and has been called from cron scripts in my shop.

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
Geoff Wild
Honored Contributor

Re: sending text from file via e mail

Download and install mpack:

http://hpux.ee.ualberta.ca/hppd/hpux/Users/mpack-1.5/

"mpack/munpack version 1.5 for unix

Mpack and munpack are utilities for encoding and decoding
(respectively) binary files in MIME (Multipurpose Internet Mail
Extensions) format mail messages. For compatibility with older forms
of transferring binary files, the munpack program can also decode
messages in split-uuencoded format.}"

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.