Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2968
  • Last Modified:

Simple Mailx script

Hi I'm looking for a very simple 2 - 3 line mailx script to send a one line message to my email address. I need this to test setting up some jobs in a scheduler program.
0
7Souls
Asked:
7Souls
  • 2
1 Solution
 
yuzhCommented:
You can do:

#!/bin/ksh
echo "my messgae" | /usr/bin/mailx -s "My Subject" you@soemwhere
exit
# End of script

or mail a text file

#!/bin/ksh
/usr/bin/mailx -s "My Subject" you@soemwhere </path-to/mymessage.txt
exit
# End of script


man mailx
to learn more details
0
 
omarfaridCommented:
Hi,

If you are going to use it in crontab:

0 3 * * * /pat/to/myscript 2> &1 | mailx -s "script results" me@mydomain
0
 
omarfaridCommented:
Hi,

I am repeating since there shouldn't be a space

0 3 * * * /pat/to/myscript 2>&1 | mailx -s "script results" me@mydomain
0
 
7SoulsData Analyst/Database AdministratorAuthor Commented:
Thanks yuzh, in addition I had to change some permissions but it ran perfectly in Contol -M.

Thanks,
7Souls
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now