How to catch the rscyn errors?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to catch the rscyn errors?
# 1  
Old 03-16-2005
How to catch the rscyn errors?

Hi,
In my code, I am running rsync, if any error comes, I have to wirte the error to temp file and I want to send this temp file content to specified email address, I am getting starnge outpout, can you pls help to solve this?
My code is:

tempfile=error.`date '+%m%d%Y_%H%M%SGMT'`
rsync -az -e ssh --delete $HOSTTOBACKUP:$SOURCE $DR_BACKUP_DIR/daily.0 >> $tempfile
X=$?
echo Error $X
if [ $X -eq 0 ]
then
echo "Rsync was completed successfully..!" | mailx -s "Rsync completed successfully" $EMAIL
else
#echo "Rsync was not successfull..!" | mailx -s "Rsync NOT completed successfully" $EMAIL
cat $tempfile | mailx -s "Rsync NOT completed successfully" $EMAIL
echo deleting temfile..
rm -rf $tempfile
fi


My standard output is :


rsync: link_stat "/home/arbuser/temp2/testrs/source123" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at main.c(723)
Error 23
send-mail: warning: the Postfix sendmail command has set-uid root file permissions
send-mail: warning: or the command is run from a set-uid root process
send-mail: warning: the Postfix sendmail command must be installed without set-uid root file permissions
rsync ended at 03162005_082920GMT



My Mail body is:


client: nothing to do: perhaps you need to specify some filenames or the --recursive option?

I need to console output tobe in my mail, whats wrong in my code?
# 2  
Old 03-16-2005
Code:
tempfile=error.`date '+%m%d%Y_%H%M%SGMT'`

rsync -az -e ssh --delete $HOSTTOBACKUP:$SOURCE $DR_BACKUP_DIR/daily.0 > $tempfile 2>&1
if [ $? -eq 0 ]   # No need for the X variable since you don't use it
then
    echo "Rsync was completed successfully..!" | mailx -s "Rsync completed successfully" $EMAIL
else
    cat $tempfile | mailx -s "Rsync NOT completed successfully" $EMAIL
    echo deleting temfile..
    rm -rf $tempfile
fi

# 3  
Old 03-17-2005
Hi,
Thanks for your help,
While running rsync, before getting error or STD out, rsync is asking password for the host. If I change like this: rsync ....... >file-for-stdout-and-stderr 2>&1
I am not getting password prompt and after the nothing is happening, if I terminate the program, I am getting mail like this:

arbuser's password:
arbuser's password:
warning: Authentication failed.
Disconnected; authentication cancelled by user (Authentication cancelled by user.).
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(359)
# 4  
Old 03-17-2005
It is not ideal, but despite not getting the password prompt you should be able still to type in the password after running the script. It is there, just you can't see it.

A cleaner solution to your particular problem would be to use ssh without password authentication.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to catch errors in a shell script ( multiple commands )?

Hi I have a shell script like that Main() { DAY=$(date +"%d-%m-%Y") TIME=$(date +"%T") Command 1 Command 2 ... Command n } I would like to catch errors from all commands in Main() and write these errors into a file , something likes this: Main if < error > then echo... (3 Replies)
Discussion started by: bobochacha29
3 Replies

2. Programming

help with C try catch

can someone give me an example of try catch in C, everytime i do it under the main, i get some try undeclared error, and dont know how to fix it... (3 Replies)
Discussion started by: omega666
3 Replies

3. Shell Programming and Scripting

Not able to catch psftp errors

Hi, While running the psftp with the below code,it is able to connect and open the ftp connection and closed the connection. But my scriptfile Test.ftp,is having the code "cd directoryname" where the directoryname does not exists. In this case i should be able to catch the error,instead it is... (1 Reply)
Discussion started by: nsrihari
1 Replies

4. Linux

Help req for...shell script to catch "db2 connect" errors ...

Hello friends, Assume that, I am trying to execute a "db2 connect" command from Linux shell prompt via a shell script called "sample" sample db2 connect to bas39 $sample If the database is not present its should display a custom error message by catching the error message given by db2.... (1 Reply)
Discussion started by: frozensmilz
1 Replies

5. UNIX for Dummies Questions & Answers

catch unzip errors

Hi everybody, I'm new to linux world and I need your help!! I'm using vi to create a .sh script that process files moving them from a directory to another and unzipping a file. I need to catch errors while moving or unzipping files. For move command, I do: mv -f... (2 Replies)
Discussion started by: Laetitia
2 Replies

6. Shell Programming and Scripting

How to catch the output

Hi All, I have a shell script for ex- #bin/ksh sqlplus user/pass << EOF select x from y; EOF my question is can I store the value of x in a variable in unix program so that i can user that value in shell script..... additionally after catching the value i want to perform some... (4 Replies)
Discussion started by: rpraharaj
4 Replies

7. UNIX for Dummies Questions & Answers

Major OS errors/Bash errors help!!!!

Hi all, dummy here.... I have major errors on entering the shell. On login I get: -bash: dircolors: command not found -bash: tr: command not found -bash: fgrep: command not found -bash: grep: command not found -bash: grep: command not found -bash: id: command not found -bash: [: =: unary... (12 Replies)
Discussion started by: wcmmlynn
12 Replies

8. UNIX for Dummies Questions & Answers

How to catch the exception

Dear friends, I am transferring some files to a windows system from Unix m/c thru FTP Script given below. echo "open $host quote USER $userid quote PASS $pwd $verbose $type cd $dir bin put $file close quit"|$ftp... (0 Replies)
Discussion started by: Vijayakumarpc
0 Replies

9. AIX

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (2 Replies)
Discussion started by: mcastill66
2 Replies

10. UNIX for Advanced & Expert Users

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (0 Replies)
Discussion started by: mcastill66
0 Replies
Login or Register to Ask a Question