Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Michael T. Richter

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Just #@$% do it!

If you have an unreliable network feed and want to run something like rsync, scp, etc. without having to babysit it a simple function can be used to prefix a command. The function looks like this:

# Function to force a command to try until it works.
# Name means "JUST #@$% DO IT!"
JFDI () {
  COMMAND=$*
  while ! $COMMAND ; do echo "Retrying..." ; done
}


Using it is simplicity itself:

# command that can fail and annoy
rsync -avz /my/local/directory/ myuser@host:~/my/remote/directory/

# command that won't give up ever
JFDI rsync -avz /my/local/directory/ myuser@host:~/my/remote/directory/
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS