The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mailx commannd - Mail and Attachment in same mail sharif UNIX for Advanced & Expert Users 6 03-19-2008 01:25 PM
mail with attachment param786 Shell Programming and Scripting 1 07-15-2007 08:20 AM
How To Add Attachment to Mail lesstjm Shell Programming and Scripting 3 12-06-2005 08:24 AM
mail attachment sushrut UNIX for Dummies Questions & Answers 3 08-27-2001 11:14 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-19-2007
Registered User
 

Join Date: Nov 2007
Posts: 1
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.
Reply With Quote
Forum Sponsor
  #2  
Old 11-19-2007
Registered User
 

Join Date: Jul 2007
Posts: 53
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 View Post
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.
Reply With Quote
  #3  
Old 11-19-2007
Read Only
 

Join Date: Nov 2007
Posts: 165
grep myvariable myfile | mailx -s mysubject me@myaddress
Reply With Quote
  #4  
Old 11-19-2007
Read Only
 

Join Date: Jul 2007
Posts: 15
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
mailx, mailx attachment

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0