Visit Our UNIX and Linux User Community


Email alert doesnt contain any message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Email alert doesnt contain any message
# 1  
Old 07-21-2009
Email alert doesnt contain any message

I have created a script which will monitor disk space in unix, it will send an email alert that will notify the specified receipients. I used echo in the mailx command but the email doesnt contain any message. I have used printf to store the message ($message2) and when tried to display on the screen using echo command the value appeared. I have also tried to use the cat command but still no message in the email. Below is the script.

#!/bin/sh
2 HOST=`uname -s`
3 LIST="apps/AI2dbFeeds apps/ai2install apps/data_transfer apps/informatica apps/oracle apps/samba apps/tsm"
4 SYSTIME=`date`
5 #SYSTIME=`date | sed -e 's/BST//'`
6 #SYSTIME=`date +"%OH:%OM"`
7 LEVEL1=40
8 LEVEL2=90
9 LEVEL3=95
10 MAILGRP="leah.dimapawi@db.com"
11 MESS="/apps/informatica/current/pmserver/Scripts/message2"
12
13 for i in $LIST
14 do
15 XXX=`df -k | grep $i|sed -e 's/%//'|awk '{print $5}'`
16 #echo $i
17 #echo $XXX
18 if [ "$XXX" -ge "$LEVEL1" ]
19 then
20 message= echo "$SYSTIME : $HOST /$i $XXX% Full!"
21 printf "$message" >> "$message2"
22 echo $message2
24 fi
25 done
26
27
28 #cat $message2 < /dev/null | mailx -s "ETL UAT - UNIX Disk Space Utilization" $MAILGRP
29 echo $message2 | mailx -s "ETL UAT - UNIX Disk Space Utilization" $MAILGRP
# 2  
Old 07-21-2009
use code tags please.

Quote:
20 message= echo "$SYSTIME : $HOST /$i $XXX% Full!"
21 printf "$message" >> "$message2"
22 echo $message2

I am quite sure there are some syntax errors.
line 20:
when you execute a command for a variable, use $().
Code:
message=$(echo "$SYSTIME : $HOST /$i $XXX% Full!")

line 21:
"$message2" must be a file. I couldn't see you have defined anything to it.


what are you getting with "echo $message2" ??
# 3  
Old 07-22-2009
This message appears on the screen when I echo $message2:

Wed Jul 22 10:57:38 BST 2009 : SunOS /apps/informatica 71% Full!

Previous Thread | Next Thread
Test Your Knowledge in Computers #152
Difficulty: Easy
In 1995, Novell transferred the Unix trademarks to the ACME Computing Company.
True or False?

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Email alert after termination

I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
Discussion started by: Jade_Michael
13 Replies

2. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

3. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

4. UNIX for Dummies Questions & Answers

IPC Message Queue. msgrcv doesnt work..

Hi everybody, this is the situation. there is a programm XYZ which opens a message queue with the key 47110815 and waits for a SIGUSR1. After receiving this signal it sends a message with type 100 and a number (as ASCII) in the message-body. I have to write a prog which frist sends the... (1 Reply)
Discussion started by: daredevil82m
1 Replies

5. UNIX for Dummies Questions & Answers

compare two files if doesnt match then display error message

hi , i have one file ,i need to search particular word from this file and if content is matched then echo MATCHED else NOT MATCHED file contains : mr x planned to score 75% in exam but end up with 74%. word to be searched id 75% please help me out . waiting for reply thanks in advance (2 Replies)
Discussion started by: atl@mav
2 Replies

6. Shell Programming and Scripting

email Alert

Hello, I want a script that will scan the file /etc/httpd/conf/httpd.conf and the folder /etc/httpd/libexec/ -bash-2.05b# grep mod_r /etc/httpd/conf/httpd.conf LoadModule rewrite_module libexec/mod_rewrite.so AddModule mod_rewrite.c -bash-2.05b# -bash-2.05b# find... (4 Replies)
Discussion started by: fed.linuxgossip
4 Replies

7. UNIX for Advanced & Expert Users

sendmail and message alert

gurus, i need to know 2 things, first: how can i send mail over the internet in case of system failures/crash? second: how can i receive SMS alert on my phone in case of failures? do i need to start any service on my box? thanks & regards abhijeet (1 Reply)
Discussion started by: abhijeetkul
1 Replies

Featured Tech Videos