Sending errors via mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending errors via mail
# 1  
Old 04-11-2016
Sending errors via mail

Hey guys.
I have created a script that mounts an external folder via sshfd, counts the number of files then do some delete and then counts the files again to get how many files have been deleted.

Then it sends the resault by mail.

My question is, how can i send via mail the errors on this script? I mean, if the password is incorrect or that it was unable to mount, or whatever.

This is the script.
Code:
paste.ubuntu.com /15759934/

thanks.

Last edited by vbe; 04-11-2016 at 11:50 AM..
# 2  
Old 04-11-2016
At the start of your script you can redirect all stderr to a file with the exec command and before exiting email that file to yourself...
Code:
exec 2>> error_file
.
.
.
mailx -s Errors your_email_address < error_file

# 3  
Old 04-12-2016
Perfect.

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

2. Shell Programming and Scripting

sending mail in perl.. No errors and also no output

Hi folks, I am trying to send an email in Perl script with the below code. I have written the code in Padre IDE and installed all the required modules(Mail::Sendmail) and executed the code. It is neither showing errors nor giving the output. I havnt received an mail after running the below... (1 Reply)
Discussion started by: giridhar276
1 Replies

3. Shell Programming and Scripting

Stop sending mail after certain number of mail

Hi guys... I am busy writing a script to notify me via an mail if my application is down. I have done that. Now I want this script to stop sending mails after five mails were sent but the script should keep on checking the application. When the application is up again that count should be... (5 Replies)
Discussion started by: Phuti
5 Replies

4. AIX

errpt kept sending errors after disk replacement

Hi, The system is a Power6 8204 with an external storage 7031. OS is AIX 5.3. I replaced a failed disk hdisk28 and put it back to the volume group. Everything looks just fine. After the replacement, errpt has kept sending "Perm DISK OPERATION ERROR". Other than the error, everything still... (1 Reply)
Discussion started by: aixlover
1 Replies

5. UNIX and Linux Applications

Got Errors while sending a transaction through ESB

We are getting below error when processing a transaction through ESB. I work for SOA admin and checked the JCA connection is working fine also code also working fine in other envs. An unhandled exception has been thrown in the ESB system. The exception reported is:... (1 Reply)
Discussion started by: KuldeepSinghTCS
1 Replies

6. Shell Programming and Scripting

Sending mail

Hi there, How can I send the automated log file, daily at 7 am to the respective mail . Thanks in Advance, Neha (2 Replies)
Discussion started by: NehaKrish
2 Replies

7. UNIX for Dummies Questions & Answers

sending mail

i want to send an email from the unix machine to the windows machine. now windows dont have any specified folder for the mail. mail has to be sent to the email-id like abc@xyz.com unix machine itself can not directly send mail. it has to be transferred via mail server. (11 Replies)
Discussion started by: parmeet
11 Replies

8. Shell Programming and Scripting

Mail sending

Dear all, how can i send mail using mailx or mail command?do i need to configure anything for sending mail?please help me.Its urgent. the version i use is Linux TDM 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386 GNU/Linux Thanks Regards, Pankaj (15 Replies)
Discussion started by: panknil
15 Replies

9. UNIX for Advanced & Expert Users

sending mail

How do I send an email with a subject and an attachment from a command prompt? (3 Replies)
Discussion started by: mskarica
3 Replies

10. UNIX for Dummies Questions & Answers

sending a mail to a mail client

Hi everyone! I'm trying to create a database monitoring script that reads an alert file and sends an error message if it can 'grep' a particular string. Is there a way to send this message to a mail client using SMTP? Even better, is there any place on this site that has these kinds of... (5 Replies)
Discussion started by: solaris73
5 Replies
Login or Register to Ask a Question