sending variable value via mailx


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sending variable value via mailx
# 1  
Old 05-27-2010
sending variable value via mailx

Hi all,
I need to send a variable value in the script through mailx. Please find the script below but its not working.

agents.sh:
Code:
agents=`grep "Tot Agents " snapshot.dbm`
if (( $? == 0 )); then
   mailx abc@gmail.com $agents
fi


Last edited by Scott; 05-27-2010 at 04:54 AM.. Reason: Added code tags
# 2  
Old 05-27-2010
Hi.

Something like:
Code:
agents=$(grep "Tot Agents " snapshot.dbm)
if [ $? -eq 0 ]; then
   echo "$agents" | mailx abc@gmail.com
fi

# 3  
Old 05-27-2010
Its working. Thanks alot.
# 4  
Old 05-27-2010
if you want to have the variable in the subject:

Code:
echo | mailx -s "this is my $VARIABLE" your@email.com

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help sending attachment via mailx

Hello, I am new to the Unix thing, and I am having trouble sending attachments via shell client putty through mailx. The command I use is $ mailx -s "Subject" user@blah.com < attachment.txt but everytime I do that it would say Cannot open attachment.txt I have the file save to my computer... (5 Replies)
Discussion started by: mrobin20
5 Replies

2. Solaris

Mailx sending but not receiving

Hi, I need help with mailx. When I run the below mailx command, it works fine because the exit code is fine, and the message is sent to /usr/mail/<id> echo "This is a test message" | mailx -s "Test" <my email address> My question is, how do I get it to reach my email address (on outlook... (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

3. UNIX for Dummies Questions & Answers

Mailx working but not sending mail

Hi All, I have a unix server on which mailx is configured . Earlier i was getting proper mails but now some mails are getting stuck and i am not receiving the emails from the server. I can see the mails in mailq. Can you please help me with this . How can i receive these emails? (2 Replies)
Discussion started by: pratikm23
2 Replies

4. Shell Programming and Scripting

sending mail through mailx command

Hi I need help to send mail through mailx command . Currenlt my program is like #!/bin/ksh -x echo " " >> path.lst MAIL_LIST='someone1@gamil.com someone2@gamil.com someone3@gamil.com' cat path.lst | mailx -s "path loaction" $MAIL_LIST echo "End" exit 0 Its work fine . But i... (3 Replies)
Discussion started by: mani_isha
3 Replies

5. AIX

Mailx Not sending

How can I check to see how/why my mailx program is not sending? /var has enough room. -Thanks ---------- Post updated at 08:48 AM ---------- Previous update was at 08:35 AM ---------- I tested the mailx to send with this command: echo "This is going to be body of the mail" |mailx... (1 Reply)
Discussion started by: tfort73
1 Replies

6. Shell Programming and Scripting

Sending attachement using mailx

Hi I tried reading docs from this forum and googled it...but i couldnt get the answer for attaching a document in mail. I need it to be the actual attachement not adding the content of the file to the body of the mail.. i used uuencode ...to encode the file but it is coming as a junk... (4 Replies)
Discussion started by: aemunathan
4 Replies

7. Shell Programming and Scripting

sending mail from perl using mailx

hi All, i am trying to send a mail from perl using mailx. the script runs fine if i hard code the file path which is to be attached to the mail. but when i give a variable containing the path of the file , perl is not able to send the file. ex: system('uuencode /attach/test.txt... (3 Replies)
Discussion started by: adityamahi
3 Replies

8. UNIX for Dummies Questions & Answers

sending mail using mailx command

Hi All, Please help me regarding sending mails using mailx command in unix. I will be glad if some one give me the sintax of this. I tried using the below but vain. mailx -s 'Hi' 'xyz@abc.com' Regards, Manas (5 Replies)
Discussion started by: manas6
5 Replies

9. Shell Programming and Scripting

sending mail through mailx

while trying to send a mail, though the output file doesn't contain any exclamatory mark(!), i am getting that in the mail with an extra line. please help me out from this ASAP. (3 Replies)
Discussion started by: pvamsikr
3 Replies

10. UNIX for Dummies Questions & Answers

sending email from mailx

hi can i know how to use mailx to send email to my lotus email account? i wan to send a file in a directory as an attachment and then email to lotus. can show me the command line to do it? thanks a lot (1 Reply)
Discussion started by: legato
1 Replies
Login or Register to Ask a Question