![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| parse through one text file and output many | sophiadun | UNIX for Dummies Questions & Answers | 14 | 02-20-2008 03:08 AM |
| parse text file | craggm | Shell Programming and Scripting | 9 | 02-26-2007 11:13 PM |
| parse text file | klick81 | Shell Programming and Scripting | 3 | 12-18-2006 09:04 AM |
| How to redirect all mails to text file? | redlotus72 | UNIX for Dummies Questions & Answers | 0 | 09-11-2006 09:27 PM |
| How to parse a text file with \034 as field and \035 as end of message delimiter? | indianya | Shell Programming and Scripting | 1 | 08-26-2005 06:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Parse Text file and send mails
Please help.
I have a text file which looks something like this aaa@abc.com, c:FilePath\Eaaa.txt bbb@abc.com, c:FilePath\Ebbb.txt ccc@abc.com, c:FilePath\Eccc.txt ddd@abc.com, c:FilePath\Eddd.txt...so on I want to write a shell script which will pick up the first field 'aaa@abc.com' and store it in some memory variable say Field1. Next I want to store c:FilePath\Eaaa.txt in Field2. Finally I want to send a mail to Field1 with Field2 as an attachment. I am new to Unix Shell scirpting and have no idea how to go about this !!!!! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Try This script
Code:
for input_dir_row in `cat sample1.txt`
do
file_name=`echo $input_dir_row | cut -d ',' -f2`
mail_id=`echo $input_dir_row | cut -d ',' -f1`
SUBJ="Send mail from Unix with file attachments"
TO=$mail_id
(
cat << !
To : ${TO}
Subject : ${SUBJ}
!
cat << !
HOPE THIS WORKS
you got the mail from sendmail utility
!
uuencode $file_name $file_name
) | sendmail -v ${TO}
done
Code:
for input_dir_row in `cat /dirpath/sample1.txt` |
|
#3
|
|||
|
|||
|
I am getting the following error
-f1:: not found > Usage: uuencode [-m] [infile] remotefile |
|
#4
|
||||
|
||||
|
are these files exist in the same machine from where you are running this script or exist on remote machine?
the file in which email id and file names are separated by comma (,) or some other delimiter? |
|
#5
|
|||
|
|||
|
Hi dhruva
I have the sample input feedfile in the same location from where I am running the script. There is no problem with that. the code is picking up the file name for the mail id. File Name : Eaaa.txt To : Eaaa.txt The field delimiter is a comma followed by a space. |
|
#6
|
||||
|
||||
|
can you check with echo what are the value coming in to variables
file_name and mail_id. and replace the line Code:
uuencode $file_name $file_name Code:
uuencode -m $file_name $file_name |
|
#7
|
|||
|
|||
|
Hi Dhruva
I tried ur newer suggestion : set -x for input_dir_row in `cat mailse1.lst` do file_name=`echo $input_dir_row | cut -f2` mail_id=`echo $input_dir_row | cut -d ',' -f1` SUBJ="Send mail from Unix with file attachments" TO=$mail_id ( cat << ! To : ${TO} Subject : ${SUBJ} ! cat << ! HOPE THIS WORKS you got mail from sendmail utility ! uuencode -m $file_name $file_name ) | sendmail -v ${TO} done Can u pls. explain what cat << ! To : ${TO} Subject : ${SUBJ} ! does exactly. From what I understand it assigns the To and Subject value and displays it on the screen. But since the time I have been using the '-m' option with uuencode i cannot see these values on the screen. What excatly is happening here ? Thanks |
|||
| Google The UNIX and Linux Forums |
| Tags |
| mailx, mailx attachment, sendmail |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|