Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple Mailx script

Posted on 2007-12-03
4
Medium Priority
?
2,962 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

715 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