Sponsored Content
Top Forums Shell Programming and Scripting redirect only the standard error output to mail Post 302153779 by barkath on Wednesday 26th of December 2007 06:55:46 PM
Old 12-26-2007
redirect only the standard error output to mail

I'm writing a script using file descriptor 2 (std error) to send an email only if the command fails or errors out but the script always emails me irrepective of whether it fails or not. It will not email the /tmp/check.error file output if doesn't error out just the mail with the subject "Cannot run check script on machB".

Any suggestions would be really appreciated. Thanks

Code:
###(Note: I have a mail problem with the one on 4th line, the other one works OK)
==========================================================================================
#!/bin/ksh

echo "" >> /tmp/sync.error

rsync -goptvz -e ssh /var/sync.all machB:/var/sync.all 2>>/tmp/sync.error

ssh -l root machB '/usr/local/check' 2>>/tmp/check.error | mail -s "Cannot run check script on machB" email@removed  

if [ $? = 0 ]
then
  date +"%D %T:$script Successfully executed." >> /dev/null 

else
  date +"%D %T:$script Unsuccessfully executed." >> /tmp/sync.error
  date +"%D %T: Exiting script." >> /tmp/sync.error
  mail -s "Cannot sync the sync.all file to machB, plz. look at /tmp/sync.error" email@removed < /tmp/sync.error

  exit 1
fi

date +"%D %T: Sync of printcap.all file completed." >> /tmp/sync.error

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

redirect standard error into log file

Hi, I am new in shell scripting. Can anyone point out what wrong of below script. If I want the error output to "sqlerror.log" and database pool data output to "bulk_main.dat". Right now, the below script, if successful execute, the data will output to bulk_main.dat && sqlerror.log both... (7 Replies)
Discussion started by: epall
7 Replies

2. UNIX for Dummies Questions & Answers

Question from a newbie. How to redirect standard output

I have a program that is sending error text to the console and I need to redirect that output to a log file. I'm brand new to Unix and don't know how to do this. Any direction would be greatly appreciated. (1 Reply)
Discussion started by: ndemos
1 Replies

3. Shell Programming and Scripting

[BASH] redirect standard error and use it inside

Hi all, Maybe my question is too simple but till now i couldn't figure about a solution :( I have a bash script scheduled in cron: <cron time parameters> my_script.sh > result.log 2>&1 By this way i can have standard output and standard error in my result.log file Now i want my script... (2 Replies)
Discussion started by: Pescator
2 Replies

4. Programming

Redirect Standard Output Multi-Process

Hi, I'm trying to compile the following code: /************** Begin <test.c> ***************/ /* * Compiled with: gcc -Wall -o test test.c */ #include <stdio.h> #include <unistd.h> int main(void) { printf("I'm process %d, son of %d \n", getpid(), getppid()); ... (5 Replies)
Discussion started by: djodjo
5 Replies

5. Shell Programming and Scripting

Redirect standard error to input of other process, 2| ?

Hello, I would like to know if there is a shell in which operations such as 2| (redirect standard error of one process to the standard input of another one) exist? I know it is possible to do it in bash with things like: (process 2>&1) | other_process but I find it a bit intricate when... (3 Replies)
Discussion started by: chlorine
3 Replies

6. UNIX for Dummies Questions & Answers

Redirect Standard output and standard error into spreadsheet

Hey, I'm completely new at this and I was wondering if there is a way that I would be able to redirect the log files in a directories standard output and standard error into and excel spreadsheet in anyway? Please remember don't use too advanced of terminology as I just started using shell... (6 Replies)
Discussion started by: killaram
6 Replies

7. Shell Programming and Scripting

How redirect standard output to a file

Hi guys, i have a script named purgeErrors.ksh, when i execute this script i need to redirect the output to a log file in the same directory, how can i do that ?? -- Aditya (5 Replies)
Discussion started by: chaditya
5 Replies

8. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

9. UNIX for Dummies Questions & Answers

Redirect Standard Error to /dev/null is not working.

Hello. When I run a .ksh that contains the command below, and there is no file available in the source location the "FILE_NAME_*.CSV not found" error is still being displayed. FILEN=$(ssh ${SOURCE_SERV} "cd ${SOURCE_LOCATION} ;ls ${FILES}") 2> /dev/null. This is interfering with the rest... (4 Replies)
Discussion started by: jimbojames
4 Replies

10. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies
GLWAITSYNC(3G)							    OpenGL 3.3							    GLWAITSYNC(3G)

NAME
glWaitSync - instruct the GL server to block until the specified sync object becomes signaled C SPECIFICATION
void glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); PARAMETERS
sync Specifies the sync object whose status to wait on. flags A bitfield controlling the command flushing behavior. flags may be zero. timeout Specifies the timeout that the server should wait before continuing. timeout must be GL_TIMEOUT_IGNORED. DESCRIPTION
glWaitSync causes the GL server to block and wait until sync becomes signaled. sync is the name of an existing sync object upon which to wait. flags and timeout are currently not used and must be set to zero and the special value GL_TIMEOUT_IGNORED, respectively[1]. glWaitSync will always wait no longer than an implementation-dependent timeout. The duration of this timeout in nanoseconds may be queried by calling glGet() with the parameter GL_MAX_SERVER_WAIT_TIMEOUT. There is currently no way to determine whether glWaitSync unblocked because the timeout expired or because the sync object being waited on was signaled. If an error occurs, glWaitSync does not cause the GL server to block. NOTES
glWaitSync is available only if the GL version is 3.2 or higher. ERRORS
GL_INVALID_OPERATION is generated if sync is not the name of a sync object. GL_INVALID_VALUE is generated if flags is not zero. GL_INVALID_VALUE is generated if timeout is not GL_TIMEOUT_IGNORED. SEE ALSO
glFenceSync(), glClientWaitSync() COPYRIGHT
Copyright (C) 2010 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/. NOTES
1. flags and timeout are placeholders for anticipated future extensions of sync object capabilities. They must have these reserved values in order that existing code calling glWaitSync operate properly in the presence of such extensions. OpenGL 3.3 03/08/2011 GLWAITSYNC(3G)
All times are GMT -4. The time now is 11:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy