Reading a file and sending mail by shell scripting?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading a file and sending mail by shell scripting?
# 1  
Old 09-19-2011
Reading a file and sending mail by shell scripting?

hi I need help urgently...i need to write a shell script which can solve the following problem....its urgent plz help me out coz m totally newbie in shell scripting....
the problem is:
Suppose I have a folder called logs. whenever some error occurs some correspondence error file is generated.
I need a script that can first find out that there is a file with the string error in it. then can read it or can directly attach it with the mail(or in html text) and can send a mail to respected mail. can you please give me help that how i vl do it(considering new in shell script). as m confused with scripting but i have to do it.

Thanks
# 2  
Old 09-19-2011
is the error string same at all times.
# 3  
Old 09-19-2011
considering it the same everytime.....
Plz help me out
# 4  
Old 10-04-2011
Hey Guys reply plz Smilie
# 5  
Old 10-04-2011
try this

iam new to shell.. just tried this for u.
Code:
if [ (grep -c error_string file1 ) -ge 1 ] ; then
$ uuencode ur_logfile|mail urmail@mail.com
fi


Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Franklin52; 10-04-2011 at 05:21 AM.. Reason: Please use code tags, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A shell script for checking the last image and sending it in attachment to mail

Hello every one. I use mutt : "mpack -s "Test" /home/pi/Pictures/2018-10-05_23_10_40.jpg my_email_addres " to send me a particular picture with the name of the data+jpg in a pictures folder, but this folder I use it for a timelapse proyect with more pictures , and what I need is... (2 Replies)
Discussion started by: maxbcn
2 Replies

2. Shell Programming and Scripting

Sending Mail via shell script

I am in need of a script that will send out emails while going through a NAT. What I have that works is as follows: display_remote_IP | sort | uniq | while read i do FOUND=0 for IP in `echo $ACCEPTABLEIP` do if ; then FOUND=1... (2 Replies)
Discussion started by: ldapguy
2 Replies

3. Shell Programming and Scripting

Sending mail from shell script

Hello All, I m trying to send mail from my unix script, I have used the below command mailx -s 'hi' email address < temp.txt It is not giving me any error,but I couldn't receive the mail Can you please help me. Many Thanks, Pragyan (6 Replies)
Discussion started by: prarat
6 Replies

4. Shell Programming and Scripting

shell script not sending mail

Hi, I have shell script which checks the filesystem check but does not send the mail. I might be missing something very simple.. could you please help? #!/bin/sh _servers="machine name" _out="/tmp/output.$$" _email="me@there.com" _sub="Disk Space Report $(date)" _mail=/usr/bin/mail... (5 Replies)
Discussion started by: Pandee
5 Replies

5. Shell Programming and Scripting

Shell script for creating log file and sending mail?

Hi , I am trying to create shell script which will help me to compare file name in two folder. There is a multiple file store in 2 folder.I want to compare that with the name. If all the file are same then send a mail that "all date is same" if not then create one log file which contain... (4 Replies)
Discussion started by: san_dy123
4 Replies

6. Shell Programming and Scripting

Shell script for sending automatic email to personal mail id

hi guys, I need a shell script to send mail automatically to my personal mail id like xxxx@hotmail.com but while experimenting with "mail" command I faced following problems. cat text1.txt | mail -s 'test mail' xxxx@hotmail.com command successfully executed but while checking for... (4 Replies)
Discussion started by: rrd1986
4 Replies

7. Shell Programming and Scripting

reading fixed length flat file and calling java code using shell scripting

I am new to shell scripting and I have to to the following I have a flat file with storename(lenth 20) , emailaddress(lenth 40), location(15). There is NO delimiters in that file. Like the following str00001.txt StoreName emailaddress location... (3 Replies)
Discussion started by: willywilly
3 Replies

8. UNIX for Advanced & Expert Users

Reading a file and sending mail based on content of the file

Hi Gurus, I am having an requirement. i have to read a list file which contains file names and send mail to different users based on the files in the list file. eg. if file a.txt exists then send a mail to a@a.com simillary for b.txt,c.txt etc. Thanks for your help, Nimu (6 Replies)
Discussion started by: nimu1979
6 Replies

9. Shell Programming and Scripting

sending a mail using shell script

Please help me in writing the script for sending an attachment through email.(For example my text file name is :abc.txt and it is in directory d:/abc) (1 Reply)
Discussion started by: anitha126
1 Replies

10. Shell Programming and Scripting

Help with GPG Scripting and sending mail when done!!!

I am very new to linux so please explain things to me like I was not from this world. I never wanted to learn linux, but since the other IT person is gone, I was the only one left. So now I have been messing around with it alot, and I really like it. Bought a few books, and CBT's to get use to it,... (2 Replies)
Discussion started by: vscott
2 Replies
Login or Register to Ask a Question