LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-05-2005, 07:26 PM   #1
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
rsync script


Hi,

Trying to write an rsync script that will rsync directories off a list of ip's contained in a file. The process of rsyncing from the list is easy but I dont quite understand how to catch if there is an error in the rsync. And if there is, skip that ip and go on with rsyncing the next ip. A section of my script is:

list=`cat list.txt | awk '{print $1}'`

for ip in $list; do
echo "IP is: $ip"
ssh $ip "(rsync -avz /home server:/backup)"
# IF rsync failed, display which ip it failed and go on with the next ip #
echo "Rsync Finished on $ip..."
done

Can anyone help me with this problem? Thank you.

-twantrd
 
Old 01-06-2005, 04:27 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
what about?

Code:
if ssh $ip "(rsync -avz /home server:/backup)" ; then
      # IF rsync failed, display which ip it failed and go on with the next ip #
       echo oh dear blah blah
else
     echo "Rsync Finished on $ip..."
fi
 
Old 01-06-2005, 05:46 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
the previous probly won't work.
I usually end up saving stderr to
a file and then checking to see
if it's got any errors in.

trouble is you can lose the context of the errors
in relation to stdout messages.

be interested if anyone knows a better way, been bugging me
for ages this sort of thing!

here's an example standalone that works...

Code:
do_it()
{

    exec 6>&2        # save stderr
    exec 2> err.log  # redirect stderr to error log

    cat <<EOF

### running:"$@"

EOF


    rsh primaappdev "$@"

    if [ -s err.log ];then   # if error log contains data

        cat - err.log   <<EOF
ERRORS:
======
EOF
    else

        : echo SUCCESS
    fi
    exec 2>&6

}

# LOOP code here
do_it date
do_it fig
Code:
billym.primadtpdev>bash  ./rsh

### running:"date"

Thu Jan  6 11:48:17 GMT 2005

### running:"fig"

ERRORS:
======
ksh: fig:  not found
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
local rsync shell script eradrix Programming 13 07-09-2005 12:57 AM
Windows Rsync Upload to Linux Rsync - permissions inspleak Linux - Software 0 10-12-2004 02:49 PM
Rsync Bandwith saver script pixie Linux - General 0 06-03-2004 03:19 AM
rsync DropHit Linux - Software 2 02-18-2004 08:54 PM
bash script HELP - dnotify > rsync GuitsBoy Programming 5 01-28-2004 09:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration