how to send contents of a file to email as a message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to send contents of a file to email as a message
# 1  
Old 12-07-2007
how to send contents of a file to email as a message

i have a file new1.txt
i want to send the contents of that file as a message to email ali@sms.com

i m using ksh script.........

plz help me
# 2  
Old 12-07-2007
Quote:
Originally Posted by ali560045
i have a file new1.txt
i want to send the contents of that file as a message to email ali@sms.com

i m using ksh script.........

plz help me
Hey,

use following ...

Subject="mailing you buddy.."
MAIL_RECIPIENTS="ali@sms.com, xyz@abccom"

cat new1.txt | mailx -s "$Subject" $MAIL_RECIPIENTS

Thanks
# 3  
Old 12-07-2007
actually i have a file

#!/bin/ksh

echo " ************************************ " >> perst
echo " The following apps are running currently indicated by their number" >> perst



for i in Archiver1 Cleaner1 Archiver2 Interpolation DBMaint ImportAdapter_CC Extrapolation ZeroConsumptionReport DBSyncListener TnsProvAdapterCheckConfig
do
count=0
count=`ps -aef | grep java | grep $i | wc -l`
echo $i $count >> perst
ps -aef | grep java| grep $i >> /tmp/new1.txt
done
echo " ********************************************** " >> perst
mail -s "Plz find the attachment for the currently Running application" naveed@cap.com < /tmp/new1.txt
Hi,
This Attachment contains the list of all the Applications Running Currently on
mdcaedn03.tu.com

Thanks
Ali Naveed
-------------------------------------------------------------------------can u tell me why i m not getting the content of file new1.txt in my mail
# 4  
Old 12-07-2007
Quote:
Originally Posted by ali560045
actually i have a file

#!/bin/ksh

echo " ************************************ " >> perst
echo " The following apps are running currently indicated by their number" >> perst



for i in Archiver1 Cleaner1 Archiver2 Interpolation DBMaint ImportAdapter_CC Extrapolation ZeroConsumptionReport DBSyncListener TnsProvAdapterCheckConfig
do
count=0
count=`ps -aef | grep java | grep $i | wc -l`
echo $i $count >> perst
ps -aef | grep java| grep $i >> /tmp/new1.txt
done
echo " ********************************************** " >> perst
mail -s "Plz find the attachment for the currently Running application" naveed@cap.com < /tmp/new1.txt
Hi,
This Attachment contains the list of all the Applications Running Currently on
mdcaedn03.tu.com

Thanks
Ali Naveed
-------------------------------------------------------------------------can u tell me why i m not getting the content of file new1.txt in my mail
Hey,

Above Boldfaced, shows redirection but whats the command in it ??
it should be ..
mail -s "Plz find the attachment for the currently Running application" naveed@cap.com < cat /tmp/new1.txt

Otherwise use pipe as I gave the example previously..

cat /tmp/new1.txt | mail -s "Plz find the attachment for the currently Running application" naveed@cap.com


Try this one..hope it'll work. Smilie
# 5  
Old 12-07-2007
Bug

instead of using the mail command, use mailx.

it should be like this:

mailx -s "Plz find the attachment for the currently Running application" naveed@cap.com < /tmp/new1.txt

I just checked the functionality of this in my unix environment:

echo "Hi hw are you" > /tmp/new1.txt
mailx -s "kshfks" myid@domain.com < /tmp/new1.txt

And I got the mail in my domain
# 6  
Old 12-07-2007
thanks now i m getting the message but after that i have written some messages
-------------------------------------------------------------

Hi,
This Attachment contains the list of all the Applications Running Currently on
mdcaedn03.tu.com

Thanks
Ali Naveed
-------------------------------------------------------------------------------
above one its not displaying, can u tell me the syntax
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture all error message in Log file and send the Log file by email

Hi I have a requirement to write a script to capture all errors in a Logfile and send the file in email. If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS. So I created a Log file and put the Appropriate... (2 Replies)
Discussion started by: dgmm
2 Replies

2. Cybersecurity

How can you send a file over Ip.NOT EMAIL

So I was just wondering... Is there a way to send a file directly to the computer..... Ive never gotten the answer and I want to know how, I keep running in to a wall :wall:. Why you may ask, well really for security reasons due to the fact that if this is done via a port I want to make sure to... (3 Replies)
Discussion started by: orszhak
3 Replies

3. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

4. Shell Programming and Scripting

Problem with sending email(to include contents of text file)

Hello, I was using a shell script for sending contents of a text file(email.report) to different users. I was using the below command in my script to send email... cat email.report | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com It was working fine all these days but now all of a sudden it... (18 Replies)
Discussion started by: smarty86
18 Replies

5. Shell Programming and Scripting

Send-file /var/log/message

Hello All i need Shell Script to send /var/log/message or another if he have or grep this file to have some info like PID or value (e.g like NFS mount - stop ) to some body in my System Thanks for Advanced (2 Replies)
Discussion started by: Hosam
2 Replies

6. Shell Programming and Scripting

error-when trying to send the message thru email.

Hi All, I want to send a message through email. I have written below code. But it is not worling. Anybody has idea, why it is not working?. export $file1=$home1/pip1.$$ mailx -s "This Message from unix" abc@yahoo.com< $file1 thanks,Mary. (5 Replies)
Discussion started by: MARY76
5 Replies

7. UNIX for Advanced & Expert Users

send a message through email to 5 people using unix script.

Hi All, I want to send a message through email to 5 people in unix script. Please let me know, how to do it.Please do reply it is urgent. Thanks, Mary. (3 Replies)
Discussion started by: MARY76
3 Replies

8. Shell Programming and Scripting

send a message through email to 5 people using unix script?

Hi All, I want to send a message through email to 5 people in unix script. Please let me know, how to do it.Please do reply it is urgent.How to do it?Please reply.thanks! Thanks, Mary. (2 Replies)
Discussion started by: MARY76
2 Replies

9. Shell Programming and Scripting

Email message if file size > 0 bytes

I want to create a script that emails a file created by Informix Ace if the file size is > 0. It is a list of exceptions. No exceptions...no message This does not work: THESIZE=`ls -lA /tmp/ds_treo.txt | awk -F' ' '{print $5}'` if then (cat $DSDIR/ds_treo.txt) | mail -s "Treo... (1 Reply)
Discussion started by: poste_d_ordure
1 Replies
Login or Register to Ask a Question