Solved

Simple Mailx script

Posted on 2007-12-03
4
2,955 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks yuzh, in addition I had to change some permissions but it ran perfectly in Contol -M.

Thanks,
7Souls
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

762 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

10 Experts available now in Live!

Get 1:1 Help Now