1

I would like to have a rsync shell script that the user will enter the folder or file to sync to another server.

i.e. - ./deploy /html/ or ./deploy /html/kuky.txt

the script will wait for the input and then will execute the rsync script please help.

0

2 Answers 2

4

Here you go:

echo "Enter file or folder path" read target if [ ! -e "$target" ] then echo $target does not exist else echo Transferring $target rsync -avzr $target [email protected]:/home/user/target_directory fi 

put this into a file called sender.sh. Then call bash sender.sh from command line.

I suggest you look up options of rsync command. They may change behavior a great deal.

0
0

Can's answer requires a user to run the script and then type the path manually, the following will allow you to use the syntax you specified in your OP:

#!/bin/bash echo -n "Transferring ${*} to server... " rsync -az ${*} <user>@<server>:/path/to/target/ 1> /dev/null echo "Done!" 

This script will take all CLI arguments given to it as source directories/files, and send them to the server.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.