Solved

Simple Mailx script

Posted on 2007-12-03
4
2,956 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now