How to extract the subject from a script which uses mailx


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to extract the subject from a script which uses mailx
# 1  
Old 02-18-2011
How to extract the subject from a script which uses mailx

Hi,

I need to extract the subject of an e-mail sent using mailx. mailx is in a a file and the command reads like the following

Ex: sendMail.sh

mailx -s ' This is the subject' $recepiant

note that anything can come within ' ' which goes to the subject.

Please help
# 2  
Old 02-18-2011
Hey, can you explain what you are trying to do just a tad bit better. Not sure I completely understand what you are trying to do.
# 3  
Old 02-18-2011
cat sendMail.sh | grep mailx | cut -d "'" -f2
This User Gave Thanks to 47shailesh For This Post:
# 4  
Old 02-18-2011
Quote:
Originally Posted by 47shailesh
cat sendMail.sh | grep mailx | cut -d "'" -f2

Thanks 47shailesh . That does it Smilie

---------- Post updated at 11:33 AM ---------- Previous update was at 11:02 AM ----------

Looks like the source is not that clear. The subject can be wrapped with either ' ' or " " it seems. Anyway if i can extract whatever between "mailx -s" and "$recepiant" it should work. Please help
# 5  
Old 02-18-2011
Code:
nawk -v qq='"' -v q="'" 'BEGIN{FS="[" q qq "]"} {print $2}' sendMail.sh

# 6  
Old 02-18-2011
Code:
sed "/mailx/ s/.*['\"]\(.*\)['\"].*/\1/" infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Variable not displaying in subject line of mailx email

Hi Newbie here with first post. I've got a shell script (ksh) whereby I run a SQL*Plus script and output the results to a file. I then check the output file in an if statement that looks like this: if ]; then export GAPNUM=`awk '{print $4}' $OUTFILE` if ] then mailx -s... (10 Replies)
Discussion started by: ltzwoman
10 Replies

2. Shell Programming and Scripting

Content of attachment is displaying along with subject in mailx

Hi All, I want to send the csv to an email address. I have tried the below two approaches. Approach1: Got error -ksh: uuencode: not found $ uuencode test_file.csv test_file.csv | mailx -s "Attaching test" msdc.kiran@gmail.com </usr/home/test_file.csv -ksh: uuencode: not found Approach2:... (6 Replies)
Discussion started by: ROCK_PLSQL
6 Replies

3. UNIX for Dummies Questions & Answers

Mailx: extract username from a file

Hey guys, I am trying to send email to the usernames listed in a ascii file. I know about the .mailrc file. I want to know if I there is a way to extract the usernames from a file and email them. I tried something like this: mailx -s "subject" '~cat... (2 Replies)
Discussion started by: Nirav4
2 Replies

4. Shell Programming and Scripting

sed to extract a multiline subject from a mail message

I'm trying to extract a subject from a mail message but my subject example has 2 lines. How can I manage to extract it and write a string at the end of it? Consider this example: From: test@domain.com Subject: Re: U =?ISO-8859-1?Q?qu=EA=3F!=3F!=3F!!_wtff_=E7=E3o_=ED=F3?= ... (6 Replies)
Discussion started by: twisterbr
6 Replies

5. Shell Programming and Scripting

Adding date to the subject using mailx

Hi , I want to add date to the subject of the email. I am using mail and used -s "SQL Loader was not able to load enid on `date` due to data error" But it didnt work. can any one help me ?? Thanks Sithara (1 Reply)
Discussion started by: sithara
1 Replies

6. Shell Programming and Scripting

executing/including command in mailx subject line

Hi, Is it possible for me to include the results from a command in the subject line? What I am looking to do is get the file count and include it into the subject line as well as the list of files in the body. Example Subject line: Currently 25 files in directory My Code: #!/bin/ksh cd... (2 Replies)
Discussion started by: ozifer
2 Replies

7. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

8. Shell Programming and Scripting

Mailx via script

Hi, using mailx, cat file1 | mailx -v -R somebody@org.com -s 'This is subject message' nobody@org.com Problem here is the subject of the email gets truncated after the first space, i.e emails are receving with subject "This" instead of "This is subject message" any idea what is wrong ?... (5 Replies)
Discussion started by: braindrain
5 Replies

9. UNIX for Dummies Questions & Answers

mailx error message : mailx: NUL changed to @

If I use the "Mail" link instead of the "mail" link to ../mailx I get this error. Mail so-n-so @whatever.com mailx: NUL changed to @ Unknown command: "postmaster" The email still goes through but i get the error. If I use "mail" it goes thru without the error. Any ideas?? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

10. UNIX for Dummies Questions & Answers

Extract or save attachment of email using mailx

Hi, Could someone help me with 'Extract or save attachment of email using mailx' Thanks, Vijay ;) (1 Reply)
Discussion started by: kandati
1 Replies
Login or Register to Ask a Question