Sending email with multiple files..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending email with multiple files..
# 15  
Old 11-01-2010
Thanks for the reply methyl,
I ran the script and i am getting this error:

Code:
Commit point reached - logical record count 64
Commit point reached - logical record count 128
Commit point reached - logical record count 150
mailx: illegal option -- m
Usage: mailx -eiIUdFntBNHvV~ -T FILE -u USER -h hops -r address
                -s SUBJECT -f FILE users
Condition table load Failed -- Return Code=1
-bash-3.00$

Can you explain to me as to what "-m" does here in the code?

Last edited by Scott; 11-01-2010 at 04:45 PM.. Reason: Code tags
# 16  
Old 11-01-2010
Question Remove back up files based on date_abc.txt not when loaded

I have several files with format 2010_10_30_abc.txt,2010_10_30_abc.csv......
and I have to remove files older than 56 days as in date with file name not the load time becuase some of the files are there from last year. So we copy file every week and keep them for 56 days and will delete after 56 days.

I am doing like this:

Code:
cd ${TGT_PATH}
if [ $? = 0 ]
then
        find . -type f  -atime +56 -exec rm -f {} \; -print > Deleted_Files_Older_Than_8W.log
fi

This is not working.
# 17  
Old 11-01-2010
Really, it should be like this, starting with the essence of the variability and expand that to file and log names:
Code:
for x in condition encounter procedure provider
do
. 
.
.
done

# 18  
Old 11-01-2010
Can you please elaborate this pls?

The script runs, and i am able to get the attachment, but no data in the attachment.
Code:
condition-20101101.log (308 B), 
encounter-20101101.log (308 B), 
procedure-20101101.log (308 B), 
provider-20101101.log (308 B).


Last edited by Scott; 11-01-2010 at 06:33 PM..
# 19  
Old 11-01-2010
Funny, ugly but works fine for me (old hp); you must be close!
Code:
(echo 'Hello,
yack yack
Best,
David
'
uuencode .profile .profile ) | mailx -m -s uuencode2x my_email@my_host

# 20  
Old 11-01-2010
Can you tell me as what's wrong with this script":
Code:
logfile1="/space/dbexport/PHR/log/condition-`date +%Y%m%d`.log"
logfile2="/space/dbexport/PHR/log/encounter-`date +%Y%m%d`.log"
logfile3="/space/dbexport/PHR/log/procedure-`date +%Y%m%d`.log"
logfile4="/space/dbexport/PHR/log/provider-`date +%Y%m%d`.log"
touch "${logfile1}"
touch "${logfile2}"
touch "${logfile3}"
touch "${logfile4}"
subject="CONDITION, ENCOUNTER, PROCEDURE & PROVIDER LOAD PROCESS FINISHED SUCCESSFULLY."
(
for logfile in "${logfile1}" "${logfile2}" "${logfile3}" "${logfile4}"
do
echo "CONDITION:" $( wc -l < /space/dbexport/PHR/data/conditionExport_test.csv),
echo "ENCOUNTER:" $( wc -l < /space/dbexport/PHR/data/encounterExport.csv),
echo "PROCEDURE:" $( wc -l < /space/dbexport/PHR/data/procedureExport.csv),
echo "PROVIDER:" $( wc -l < /space/dbexport/PHR/data/providerExport.csv);
done
for logfile in "${logfile1}" "${logfile2}" "${logfile3}" "${logfile4}"
do
attachment=`basename "${logfile}"`
"${logfile}" | uuencode "${attachment}"
echo ""
done
) | mailx -m -s "${subject}" "$to" id11355@gmail.com

1) I am able to get the log file as attachement,, but the file has no data..
2) I am getting the output as:
Code:
CONDITION: 2000
ENCOUNTER: 1000
PROCEDURE: 1000
PROVIDER: 150
CONDITION: 2000
ENCOUNTER: 1000
PROCEDURE: 1000
PROVIDER: 150
CONDITION: 2000
ENCOUNTER: 1000
PROCEDURE: 1000
PROVIDER: 150
CONDITION: 2000
ENCOUNTER: 1000
PROCEDURE: 1000
PROVIDER: 150

Required output should be:
Code:
CONDITION: 2000
ENCOUNTER: 1000
PROCEDURE: 1000
PROVIDER: 150

Moderator's Comments:
Mod Comment Use code tags, please.

Last edited by Scott; 11-01-2010 at 06:41 PM.. Reason: Final warning to add code tags
# 21  
Old 11-01-2010
Hi.

Your first for loop is completely unnecessary. Remove it.

And you could change:
Code:
"${logfile}" | uuencode "${attachment}"

to
Code:
uuencode "$logfile "$attachment"

(the point of this is only for aesthetic reasons, so the attachment name looks nicer in the email)

Try adding an extension so that it's associated with a program:

i.e.
Code:
attachment=${logfile##*/}.txt

This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending multiple files using uuencode command

Hi All, I want to send multiple CSV file using below code. In Result folder, we have multiple CSV files. However, I want to catch only Summary CSV files. I was trying using *, % with different combination. However, not able to do so. From below code, I could send only one file... (1 Reply)
Discussion started by: Swapnil Mawle
1 Replies

2. Shell Programming and Scripting

Sending files to multiple emails

Hi All, I want to send each file to each email id as below. Instead of writing saparate 10 mail commands can we do it in a simple step. file1.csv to raghu.s@hps.com file2.csv to kiran.m@hps.com file3.csv to kenni.d@hps.com file4.csv to rani.d@hps.com file5.csv to sandya.s@hps.com... (2 Replies)
Discussion started by: ROCK_PLSQL
2 Replies

3. Solaris

Sending Mails to the Multiple Email Address

Hi All, I am pretty new to the mail service in Sun Solaris 5.10. If anybody help me in writing a script for the multiple recipient with subject and the body would be a helpful. Kindly help... Thanks in advance. :) Warm Regards, Pramod (5 Replies)
Discussion started by: Pramod_009
5 Replies

4. Shell Programming and Scripting

sending multiple files along with mail message using uuencode

Hi, I have a requirement to send a mail with multiple files attached to it and along with the text message in the mail. I am trying sumthing like below but it only sends me the text message and no files attached to the mail. ---------------------------------------- ( uuencode file1... (1 Reply)
Discussion started by: sachinkl
1 Replies

5. UNIX for Dummies Questions & Answers

Zipping files and sending email

Hi, I need to zip 4 files and send an email attaching the zipped files... Pls help.. Win ---------- Post updated at 10:49 AM ---------- Previous update was at 10:36 AM ---------- Hi, I need to convert 4 text files into xls,zip these 4 files and send an email attaching the... (2 Replies)
Discussion started by: win4luv
2 Replies

6. HP-UX

Sending email to multiple IDs

Hi, I am trying to send an email to multiple IDs from Unix script. I have given the EmailIds in a file and trying to use the file as input in the script. > cat Email EmailID = "abc@xyz.com cbz@xyz.com" In my script I have . /Email mailx -s "subj" $EmailID This fails with the... (3 Replies)
Discussion started by: sangharsh
3 Replies

7. HP-UX

Sending Unix files as attachments in an email

Hi, I am executing the following command in order to send a file as an attachment: mailx -s "Subject" emailID@xyz.com < Testfile.txt Instead of attaching the file Testfile.txt, it is writing the contents of the file in the email message body. Please advise on how I can send the file as an... (7 Replies)
Discussion started by: sangharsh
7 Replies

8. Shell Programming and Scripting

Sending an email with more than one files

Hi, I would like to send an email with more than one attachement. I am using uuencode. I want to achive by suing uuencode. Also please let me know other ways. -Thambi (7 Replies)
Discussion started by: thambi
7 Replies

9. Shell Programming and Scripting

Sending mutiple files thru email to lotus notes

Hi All, I am currently using the following script to send the single file to one/more email addresses. I need to send mutilple files at same time, are there anyway I could modify the script or write new one to accomplish the same. Script *************** #!/bin/ksh # Author: Manish... (4 Replies)
Discussion started by: lapisguy
4 Replies

10. Shell Programming and Scripting

Sending Multiple Files through email

Hi Everyone, I'm using the uuencode command with the mail command to send out emails through a UNIX script. The problems is that i have a number of gif files that i need to attach to a single email but the number and name of the gif files is not static. Example today the folder home/Desktop may... (4 Replies)
Discussion started by: nbvcxzdz
4 Replies
Login or Register to Ask a Question