1752646 Members
6049 Online
108788 Solutions
New Discussion юеВ

sendmail Q

 
himacs
Super Advisor

sendmail Q

Hi gurus,

I have a script which takes the login details from the number of servers and output will be copied to a folder.So after execution this folder will contain atleast 7 files.My Q is how could i send these 7 files to my mail id using sendmail at a shot.

main part of script given below

ssh noor@$i /home/noor/login.sh >>/syslogs/logins/$i.$DATE


plz advise on this


regards
himacs


2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: sendmail Q

Hi:

If we can assume that the directory contains only files you want to mail, then you could do something simple like:

#!/usr/bin/sh
cd /path || exit 1
for FILE in $(ls)
do
mailx -s "Please review" himacs < ${FILE}
done

...which would send one file per mail.

Regards!

...JRF...

himacs
Super Advisor

Re: sendmail Q

HI James,

Thanx for the reply..

Instead of writing new script ,can we add mailx command with the below script..

ssh noor@$i /home/noor/login.sh >>/syslogs/logins/$i.$DATE

so that with single line or script, the all works be done.like executing login script,directing otput to a folder and again sending the same with mailx..

regards,

himacs