BASH script that sends text message or email


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers BASH script that sends text message or email
# 1  
Old 07-15-2010
BASH script that sends text message or email

Hi,

I have a BASH shell script that batch processes data. I often start this script before I leave to go home for the day, and leave it processing over night. It has come to my attention that it would be very useful for me to add the capability of making the script notify me about certain things (erroring on a file, completing a processing run, etc.). How can I make the script email me or send me a text message to my phone? Thanks for any help.

Mike
# 2  
Old 07-15-2010
email function for a script
Code:
# usage: email "message to send"   "email address"
email()
{
     echo "$1"  | /usr/bin/mailx -s "Problem with script"   $2
}
# example
email 'the script bombed on line 9'  'me@my.com'

# 3  
Old 07-15-2010
Hi Jim,

Thank you very much for the reply! A few questions:

- I didn't appear to have mailx installed. When I typed mailx the following was returned:

Code:
mike@mikebrown-desktop:~/Desktop$ mailx
The program 'mailx' can be found in the following packages:
 * heirloom-mailx
 * mailutils
Try: sudo apt-get install <selected package>

I installed mailutils (GNU Mailutils - GNU Project - Free Software Foundation (FSF)). Was that best option? Supposedly it has replaced mailx.

- Do you have any advice on how to use a unix mail function to check mail at a specific email address. I wonder if it is possible to receive an email from my script, respond to that email, and have the script perform a task depending on my response. Thanks again for your help.

Mike

---------- Post updated at 03:27 PM ---------- Previous update was at 02:50 PM ----------

I also wonder if there is additional configurations I need to do because I have not received any of the emails I sent myself.

Mike
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash function to suppress warning message for specific text and display prompt

In the below bash function multiple variants are input and stored in a variable $variant, and each is written to an out file at c:/Users/cmccabe/Desktop/Python27/out.txt stored on a separate line. # enter variant phox2b() { printf "\n\n" printf "What is the id of the patient getting... (0 Replies)
Discussion started by: cmccabe
0 Replies

2. Shell Programming and Scripting

Help with logrotate email bash script

Hello, I am trying to basically take the last 4 hours of a log file and pipe it into a new file and then send those contents out via email. Where do I begin with this? Thank You in advance ! (1 Reply)
Discussion started by: endjoi
1 Replies

3. Shell Programming and Scripting

Script to Alert a file and sends an email

Hello All, I need a script which alerts me when a files arrive in a directory. I don't need every file. but i need some specific pattern file. And i need to get automatic email gettin as an alert For Example: /a/b/c/ : directory format of file should take regualr expression or manually... (2 Replies)
Discussion started by: krux_rap
2 Replies

4. Shell Programming and Scripting

Script to cut the first word in Message Text

Hi, In my shell script, I am connecting to database and querying multiple columns in a table. MESSAGE_TEXT=`sqlplus -s /nolog <<end_log_stmt set heading off set feedback off set verify off set termout off set pages 0 CONNECT APPS/$USER_PWD Select order_number, id, error_message... (6 Replies)
Discussion started by: balajiora
6 Replies

5. Shell Programming and Scripting

how to know if the mailx command really sends the mail to the email address?

Hi guys, I have a question about the returning message of the mailx command. if I run a mailx command, how can I know if the email has been sent to the email address? If the email address doesn't exist, is there any error message returned? If yes, how can I get the error message? Thanks... (3 Replies)
Discussion started by: sheenshine
3 Replies

6. Shell Programming and Scripting

Running script that sends an html formatted email fails when its run as cronjob

Hi Im very new at working with unix and this problem I simply can not understand. I know there are a lot of threads about problems with shell scripts behaving differently when run from a terminal and from a cronjob. I have tried everything(almost) but I still havent cracked this problem. Im... (15 Replies)
Discussion started by: Nightowl
15 Replies

7. Shell Programming and Scripting

write the script to get the file size and sends an email

hi all Anybody have an idea to write the script to get the file size and sends an email when file size increse more than 10mb. thanks (10 Replies)
Discussion started by: s_linux
10 Replies

8. Shell Programming and Scripting

blink a text/message in a ksh script

can anyone tell me how to bink a text in a ksh script for e,g file 1 #!/bin/ksh "this is my file" ----------------------------------------------- i want "this is my file" text to blink.thanks (9 Replies)
Discussion started by: ali560045
9 Replies

9. UNIX for Advanced & Expert Users

send a message through email to 5 people using unix script.

Hi All, I want to send a message through email to 5 people in unix script. Please let me know, how to do it.Please do reply it is urgent. Thanks, Mary. (3 Replies)
Discussion started by: MARY76
3 Replies

10. Shell Programming and Scripting

send a message through email to 5 people using unix script?

Hi All, I want to send a message through email to 5 people in unix script. Please let me know, how to do it.Please do reply it is urgent.How to do it?Please reply.thanks! Thanks, Mary. (2 Replies)
Discussion started by: MARY76
2 Replies
Login or Register to Ask a Question