The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 copy file to/from an the the same directory on a remote machine
Author: culley 
Date:   20-04-03 14:17

Here is a little script I use every day. It created 3 links to the script: rget, rput and rs. calling the script by the different links does different things:

rput: scp a file to a remote machine. For example if you are in /home/foo and you type:

rput bar

then this expands to:

scp bar example.com:/home/foo/bar

rget reverses this to copy from the remote machine to the local machine.

And rs calls rsync and pushes all files in the current directory to the remote directory. rs requires a file named .rs in the current directory-- this file is a list of all files to exclude from the rsync



#!/bin/sh
# $Id: publish.sh,v 1.1 2002/11/24 14:49:27 culley Exp $
#
#

host="example.com"
dir=`pwd`

script=$0


case $script in

*rput)
cmd="scp $1 $host:$dir/$1"
break
;;

*rget)
cmd="scp $host:$dir/$1 ."
break
;;

*rs)
echo "rsync -zvt --modify-window=15 --progress -e ssh --exclude-from=$dir/.rs * $host:$dir/"
rsync -zvt --modify-window=15 --progress -e ssh --exclude-from=$dir/.rs * $host:$dir/
exit;
;;

*)
echo valid commands:
echo " rs <file_names> using rsync send all changes in the current directory to the server."
echo " rput <file_name> using scp send a singlular file to the server"
echo " rget <file_name> using scp get a singlular file from the server"
exit
;;

esac

echo $cmd
exec $cmd

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org