Solved

Simple Mailx script

Posted on 2007-12-03
4
2,957 Views
Last Modified: 2013-12-27
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
Comment
Question by:7Souls
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 250 total points
ID: 20400090
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 20400516
Hi,

If you are going to use it in crontab:

0 3 * * * /pat/to/myscript 2> &1 | mailx -s "script results" me@mydomain
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20400521
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
 

Author Closing Comment

by:7Souls
ID: 31412472
Thanks yuzh, in addition I had to change some permissions but it ran perfectly in Contol -M.

Thanks,
7Souls
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IBM AIX Cannot Install AIX ToolKit Applications for Linux 11 151
AIX  NFS  question 1 138
how to check for shares on aix 1 80
UNiX Script filesystem space usage 19 74
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question