Trying to email text, getting blank email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to email text, getting blank email
# 1  
Old 11-23-2011
Trying to email text, getting blank email

Hello, and thank you for help in advance, i seem to have this script working, except for the email part, it sends me a blank email, am i not redirecting the output of my text file the right way?


Code:
#!/usr/bin/ksh

rm installed_zones.txt

installed=/home/xxx/stuff/installed_zones.txt

for EACH in `cat serverlist.txt`
do
ssh $EACH zoneadm list -ipc | grep running | grep -v "global" >> installed_zones.txt
done

if [ -s installed_zones.txt ] ; then
cat /home/xxx/stuff/installed_zones.txt | mail xxx@xxx.com
               exit
else
echo NO INSTALLED ZONES  | mail xxx@xxx.com
               exit
fi


Last edited by BG_JrAdmin; 11-23-2011 at 06:26 PM..
# 2  
Old 11-23-2011
Maybe just -s "subject..." missing ?
# 3  
Old 11-23-2011
Code:
for EACH in `cat serverlist.txt`
do
ssh $EACH zoneadm list -ipc | grep running | grep -v "global" >> installed_zones.txt
done

Useless use of cat, dangerous use of backticks. You don't need to run grep 18,000 times for 9,000 hosts either. This would be faster and more reliable:

Code:
while read EACH
do
        ssh "$EACH" zoneadm list -ipc
done < serverlist.txt | grep running | grep -v "global" > installed_zones.txt

Code:
cat /home/galanteb/stuff/installed_zones.txt | mail xxx@xxx.com

Another useless use of cat, though probably not as big a deal. Redirect in a file with < instead. Also, as vbe says, try giving it a subject.

Code:
mail xxx@xxx.com -s "subject" < /home/galanteb/stuff/installed_zones.txt

# 4  
Old 11-23-2011
i could not get "mail" to work, this is solaris 10. this below finally worked. I appreciate your help!

Code:
/usr/ucb/mail -s "ZONES INSTALLED BUT NOT RUNNING" me@x.com < installed_zones.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a blank line in between two O/Ps in tabular format which gets received over email

Hi Guys, I am stuck in between and seeking help here. Requirement: A script that will run every morning which will connect to Mysql database and run the query to inform us about the holidays (it will also check if there were any holidays during last 2 business days). So the three queries are... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

2. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies

3. SuSE

Send outgoing email to my GroupWise email

Dear users, I have Linux server whose versions are Suse 10 SP 3 and Suse 11. I am trying to send email from these servers to my GroupWise email account. In /etc/postfix/main.cf file, The current value of MYHOSTNAME is LINUX.LOCAL. What should be the right value of MYHOSTNAME? Is... (0 Replies)
Discussion started by: JDBA
0 Replies

4. 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

5. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

6. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

7. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

8. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question