search a string and mail it as attachment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search a string and mail it as attachment
# 1  
Old 11-19-2007
search a string and mail it as attachment

Hi All,

I need to search a text in a string, assign it to a variable.

Ex :

I need to get the number that has gif extension. The number is not constant. The search value should return as 1174499845 from the following string.

x 1174499845.gif, 133982 bytes, 262 tape blocks

Go to relevant directory, search for the the variable (example 1174499845) in the directory.

if exists Mail it as attachment else display "required attachment" not available.


Thanks in advance.


Jagadeesh Tata.
# 2  
Old 11-19-2007
Here's a rough ideal on what you need to do.. Assuming you are just looking for one file at a time.

ls ${DIR} | grep "$VARIABLE"
if [ $? -eq 0 ]
then
<do mail command here, unsure how to do attachment as this moment>
fi


Quote:
Originally Posted by jagadeeshtata
Hi All,

I need to search a text in a string, assign it to a variable.

Ex :

I need to get the number that has gif extension. The number is not constant. The search value should return as 1174499845 from the following string.

x 1174499845.gif, 133982 bytes, 262 tape blocks

Go to relevant directory, search for the the variable (example 1174499845) in the directory.

if exists Mail it as attachment else display "required attachment" not available.


Thanks in advance.


Jagadeesh Tata.
# 3  
Old 11-19-2007
grep myvariable myfile | mailx -s mysubject me@myaddress
# 4  
Old 11-19-2007
Text files can easily be sent as the body of an email as shown above. If you need to send something as an attachment, you have to encode it. I like mpack, but have used uuencode as well. Here's my snippets:

cat filename | uuencode attachmentName | mailx -m -s “Subjest” someone@somewhere.com

#/usr/local/bin/mpack -s "Test Email" -c application/octet-stream ./oracle_trace_file.trc me@myaddress.com
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search the string in the active log and send mail

Hello, I wanted to search specific string in the acitve log file and send an email if the search string found in the log. Log file is written by application all the time. So, script has to search if any new log entry has the specific string for example " sample exception" and send an email. (1 Reply)
Discussion started by: balareddy
1 Replies

2. Shell Programming and Scripting

Mail attachment

Hi, I want to send an attachment and content in a single mail using unix command can anyone pls help me? Thanks Naveen A (6 Replies)
Discussion started by: Pranaveen
6 Replies

3. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

4. Shell Programming and Scripting

Getting mail with no Attachment

Hi All, my requirement send a mail with attachment a abc.txt file. below is the shell script. #!/usr/bin/ksh set -x #DIR=/appldata/download/mail MAILTO="krupa.behera@kk.com" SUBJECT="Report" BODY="Hi All," ATTACH=/projects/psoft/hrdw/pushreports/crons/temp_out... (5 Replies)
Discussion started by: krupasindhu18
5 Replies

5. Shell Programming and Scripting

Mail Attachment...

Hi All, I am new to unix. I have written the script to identify the delimiter count for my source file and the output I have to capture in another file and that file should sent to mail with attachment. I have tried to send the attachment with below script . But I am not able to do that. Any... (2 Replies)
Discussion started by: suresh_target
2 Replies

6. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

7. Shell Programming and Scripting

Mail attachment with unix mail

Hi Could someone help me with the details on how to send an attachment through mail in unix. I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps. Regards Ajay (2 Replies)
Discussion started by: ajaykumarboyana
2 Replies

8. Shell Programming and Scripting

Search for string and send mail

Hi, I need to find if there is any error in the last few lines of the log file and send a mail accordingly.For example, Following errors can be logged in the log file. ERR_1="DB Connection not established" ERR_2="Server Unloading" I need to find if these errors are found in the log file and... (1 Reply)
Discussion started by: AnneAnne
1 Replies

9. UNIX for Advanced & Expert Users

mailx commannd - Mail and Attachment in same mail

Hi , I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Discussion started by: sharif
6 Replies

10. UNIX for Dummies Questions & Answers

mail attachment

This question has been asked many time before. I did search other questions. But was not able to work out. Really sorry for repeating the same question. I have mail and mailx and sendmail installed. It Tried this uuencode FILENAME.txt FILENAME.txt | mail mymail@yahoo.com the attachment... (3 Replies)
Discussion started by: sushrut
3 Replies
Login or Register to Ask a Question