Im somewhat beginner in bash scripting. I have here part of script that uploades files to sftp server. Then it shoud move files to other directory.
Else echo info about no files in source_dir. Problem is that its not moving files and is looping back to sftp login after files are already uploaded.
cd /dest_dir/
for file5 in *.test
do
if test -f $file5
then
echo 'some text.'
((
echo "
cd /dest_dir/
lcd /source_dir/
mput *.test
exit
"
) | sftp "user"#"host")
sleep 3
mv /source_dir/$file5 /source_dir/test/
else
echo -e 'some text'
fi
There is normally no reason to check that the files you are looping over actually exist. If a file could disappear between the for and the test, it could just as well disappear between the test and the echo instead, in which case you end up referring to a file which no longer exists anyway.
#!/bin/bash
shopt -s nullglob # bash-only feature
cd /dest_dir/
(#echo "cd /dest_dir/" # no use, you already did above
echo "lcd /source_dir/"
for file in *.test; do
echo put "$file"
done
echo "exit" ) | sftp "user"#"host"
mv *.test /source_dir/test/
This opens a single scp connection for all the files. It has the distinct disadvantage that if one of the files fails for some reason, the script doesn't catch that.
Apart from the shopt -s nullglob this should be portable to Bourne shell in general.
thank you for tips. I made it: with loging:
SFTP_HOST="host"
SFTP_LOGIN="USER"
cd /path/
mylog=/path/sftp_session_$(date "+%Y_%m_%d").log
echo "$(date "+%Y-%m-%d %H:%M:%S") - text" >> $mylog
let licz5=`ls|wc -l`
let jest_plik=0
for file5 in *.test
do
if test -f /patch_source1/$file5
then
let jest_plik=1
echo "$(date "+%H:%M:%S") - transfer pliku "$file5" na serwer "$SFTP_HOST >> $mylog
fi
if test -f /source_patch2/$file6
then
echo "$(date "+%H:%M:%S") - transfer pliku "$file6" na serwer "$SFTP_HOST >> $mylog
fi
if test -f /source_patch3/$file7
then
echo "$(date "+%H:%M:%S") - transfer pliku "$file7" na serwer "$SFTP_HOST >> $mylog
fi
if test -f /source_patch4/$file8
then
echo "$(date "+%H:%M:%S") - transfer pliku "$file8" na serwer "$SFTP_HOST >> $mylog
fi
done
if test $jest_plik -eq 1
then
echo 'text.'
(echo 'cd /dest_dir/
lcd /source_p_1/
mput *.test
lcd /source_p_2/
mput *.test
lcd /source_p_3/
mput *.test
lcd /source_p_4/
mput *.test
exit') | sftp $SFTP_LOGIN#$SFTP_HOST
echo "$(date "+%H:%M:%S") - send ok." >> $mylog
else
echo -e 'text'
fi
Related
For some reason commands are not running after the first if statement.
"/usr/local//backup.sh: sleep: not found" for example..
The first if statement goes like:
if [ "$command" == "start -c" ]; then
echo -e "${ORANGE}Starting website backup...${E}"
sleep 1
DT=`date +%Y-%m-%d`
echo -e "${ORANGE}Started backup at $DT ${E}"
sleep 1
tar -zcvf web-$DT.tar.gz /usr/local/www/nginx
echo -e "${ORANGE}Compatced files, moving to backup directory${E}"
sleep 1
mv web-$DT.tar.gz $PATH/web-$DT.tar.gz
echo -e "${CYAN}Moved to backups ($PATH/web-$DT.tar.gz)\nDo you want to upload to ftp?${E}\n${CYAN} 'y' or 'n'?${E}"
read answer
if [ "$answer" == "y" ]; then
echo -e "${ORANGE}Uploading to ftp server...${E}"
sleep 1
if ftp -in -u ftp://$USER:$PASS#$HOST/Backups/f $PATH/web-$DT.tar.gz; then
echo -e "${GREEN}Uploaded! Bye!${E}"
else
echo -e "${ORANGE}Couldn't upload with ftp command, trying with curl...${E}"
sleep 1
curl -T "$PATH/web-$DT.tar.gz" -u $USER:$PASS ftp://$HOST/Backups/f/
echo -e "${GREEN}Uploaded! Bye!${E}"
fi
else
echo -e "${GREEN}Bye!${E}"
fi
Everything works fine inside this statement, however, after the elif compassion it just doesn't.
Here's the problematic code:
elif [ "$command" == "start -d" ]; then
echo -e "${ORANGE}Starting database backup...${E}"
sleep 1
DT=`date +%Y-%m-%d`
echo -e "${ORANGE}Started backup at $DT ${E}"
sleep 1
umask 177
echo -e "${ORANGE}Dumping database 'account'\n${E}"
mysqldump --user=$DBUSER --password=$DBPASS --host=$HOST account > $PATH/account-$DT.sql
sleep 1
echo -e "${ORANGE}Dumping database 'game'\n${E}"
mysqldump --user=$DBUSER --password=$DBPASS --host=$HOST game > $PATH/game-$DT.sql
sleep 1
echo -e "${ORANGE}Dumping database 'forum'\n${E}"
mysqldump --user=$DBUSER --password=$DBPASS --host=$HOST forum > $PATH/forum-$DT.sql
sleep 1
echo -e "${CYAN}Moved to backups ($PATH/<database-date>.sql)\nDo you want to upload to ftp?${E}\n${CYAN} 'y' or 'n'?${E}"
read answer
if [ "$answer" == "y" ]; then
echo -e "${ORANGE}Uploading to ftp server...${E}"
sleep 1
curl -T "$PATH/account-$DT.sql" -u $USER:$PASS ftp://$HOST/Backups/f/Databases/
curl -T "$PATH/game-$DT.sql" -u $USER:$PASS ftp://$HOST/Backups/f/Databases/
curl -T "$PATH/forum-$DT.sql" -u $USER:$PASS ftp://$HOST/Backups/f/Databases/
sleep 1
echo -e "${GREEN}Uploaded! Bye!${E}"
else
echo -e "${GREEN}Bye!${E}"
fi
and then I just ended it..
else
echo -e "${RED}Sorry! Not found${E}"
fi
As you can see there's spaces in the if statements and all of that, so what's wrong with this??
I've the #!/bin/bash up top as well, all the variables exist too.
You seem to have overwritten the value of the PATH variable at some point in your code. The shell needs that variable in order to know where to find programs like sleep (Hence the "not found" error). Name your path variable something else.
OK, so, I'm trying to create a script that...
a. Will look in a folder where I drop my txt notes, and if any of them starts with "a2c_" it will recognize it as an "aria2c download list". Which brings as to...
b. Will pass the first of the matching files to aria2c, together with a directory name similar to the txt file, so that it will download each URL found in the txt to the same-named directory.
I've ended up with this..:
#!/bin/bash
#PARAMETERS: _______________________________
workingdir="/home/username/downloads/"
#___________________________________________
echo Working dir is: $workingdir
mkdir -p $workingdir
echo "Making dir"
cd $workingdir
if [ -f a2c_* ]
then
echo "Found files"
mkdir -p !a2c_downloaded
echo "Making !a2c_downloaded dir"
counter=0
echo "Set counter to 0"
for f in a2c_*.txt
do
counter=$((counter+1))
echo Download List File is: $f
echo $counter file processing.
tempfile=${f%%.*}
tempfile="`echo "$tempfile" | sed ' s/a2c_//' `"
downdir=$tempfile
echo Download Dir is: $downdir
mkdir -p $downdir
echo ___________________________________________
echo $endfilename
aria2c --auto-file-renaming -i $f -d $downdir --force-sequential
echo "Will download $f to $downdir"
sleep 5
mv $f !a2c_downloaded/
done
else
echo "No files found"
fi
...that worked when I tested it. Today, one day later, I throw some a2c_*.txt files in the dir and I'm met with "unexpected operator" errors. Any ideas? And is there an easier way to accomplish what I'm trying to do?
Thanks.
_UPDATED: _________________________________
#!/bin/bash
#PARAMETERS: _______________________________
workingdir="/home/username/downloads/"
MatchPattern="a2c_*"
#___________________________________________
echo Working dir is: $workingdir
mkdir -p $workingdir
echo "Making dir"
cd $workingdir
#if [ -f a2c_* ];
#if [ find . -maxdepth 1 -type f -name "a2c_*.txt" 2>/dev/null | grep "a2c_*" ]
#if [ -f a2c_* ]
#if [ "$?" = "0" ];
echo "Match Pattern set as $MatchPattern"
echo "Now looking in $workingdir for $MatchPattern"
echo "Manual list:"
echo "_________________________________________"
MatchList=$(ls -1 "$MatchPattern")
echo "$MatchList"
echo "_________________________________________"
if ls -1 $MatchPattern >/dev/null 2>&1
then
echo "Found files"
mkdir -p !a2c_downloaded
echo "Making !a2c_downloaded dir"
counter=0
echo "Set counter to 0"
for f in a2c_*.txt
do
counter=$((counter+1))
echo "Download List File is: $f"
echo $counter file processing.
tempfile=${f%%.*}
tempfile="`echo "$tempfile" | sed ' s/a2c_//' `"
downdir=$tempfile
echo "Download Dir is: $downdir"
mkdir -p "$downdir"
echo ___________________________________________
echo "$endfilename"
aria2c --auto-file-renaming -i "$f" -d "$downdir" --force-sequential
echo "Will download $f to $downdir"
sleep 5
mv "$f" !a2c_downloaded/
done
else
echo "No files found"
fi
...The above works, after some fixes http://www.shellcheck.net/ told me to do. Problem is, it advises me to use double quotes in line:
if ls -1 $MatchPattern >/dev/null 2>&1
like
if ls -1 "$MatchPattern" >/dev/null 2>&1
..."Double quote to prevent globbing and word splitting.", but when I do, the script stops working for me. Should I leave it as it is? It seems to be working fine - for now.
Instead of
if [ -f a2c_* ]
then
You can try this:
file_exists() {
for _i do
[ -f "$_i" ] && break
done
}
and then
if file_exists a2c_*
then
I wrote a script in bash (a neophyte) that creates a file on the local flash drive and writes random data on it until it fills up. It then copies the file to an external usb drive and deletes the local file. Once the file has been filled up and it is on the usb drive, it is copied back to the local NAND flash, deleted, and copied from the usb flash drive again (indefinitely, until the user stops it or an error occurrs, whichever is first - this is in a while loop). When I run the script it displays:
nand_test.sh: line 19: /tmp/activity.log: Text file busy
nand_test.sh: line 19: /tmp/activity.log: Text file busy
nand_test.sh: line 19: /tmp/activity.log: Text file busy
nand_test.sh: line 19: /tmp/activity.log: Text file busy
and just hangs there. Can someone tell me if there are errors in my script? I'm very green when it comes to bash. Below is the code:
LOG="/tmp/activity.log"
function if_error
{
if [[ $? -ne 0 ]]
then
print "$1 TIME:$TIME" | tee -a $LOG
exit $?
fi
}
#whenever the echo command is ran this function allows me add a timestamp
function echo {
/bin/echo `date` $* | $LOG
}
#condition below checks if activity.log exists. If not, it creates it.
mydir="/media/myusb"
chmod +x /tmp/activity.log
activity="/tmp/activity.log"
if [ -e "$activity" ];then
echo - "$activity" LOG ALREADY EXISTS >> "$activity"
else
> /activity.log
#echo - "$activity" LOG HAS BEEN CREATED >> "$activity"
fi
#condition below checks if myusb directory is created. If not, it creates it.
if [ -d "$mydir" ];then
echo - "$mydir" ALREADY EXISTS >> "$activity"
else
mkdir /media/myusb
#echo - "$mydir" HAS BEEN CREATED >> "$activity"
fi
#check if external usb has been mounted. if not mount it.
device0="/dev/sda1"
if [ -b "$device0" ];then
echo - "$device0" IS ALREADY MOUNTED >> "$activity"
else
mount LABEL=MYFLASH /media/myusb
#echo - "$device0" HAS BEEN MOUNTED >> "$activity"
fi
#condition below checks if testfile.txt has been created. If not, it creates it.
testfile="/storage/testfile.txt"
if [ -e "$testfile" ];then
echo - "$testfile" FILE ALREADY EXISTS >> "$activity"
else
>> /storage/testfile.txt
#echo - "$testfile" HAS BEEN CREATED! >> "$activity"
fi
dd if=/dev/urandom of=/storage/testfile.txt >> "$activity"
ret=$?
if_error "urandom data failed writing to testfile.txt"
if [ "$ret" gt 0 ];then
echo - "NAND FLASH DATA TEST FAILED >> "$activity"
else
cp "$testfile" "$mydir"
fi
rm "$testfile"
sync
sleep 3
while [ -e "/media/myusb/testfile.txt" ]
do
cp /media/myusb/testfile.txt /storage
sync
DIFF= diff /media/myusb/testfile.txt "$testfile"
if [ "$DIFF" != "" ];then
echo - "ERROR: THE FILE HAS BEEN MODIFIED" >> "$activity"
else
echo - "FILE COMPARISON SUCCESSFUL" >> "$activity"
fi
rm "$testfile"
sync
You have this line at the top:
LOG="/tmp/activity.log"
and then:
/bin/echo `date` $* | $LOG
It doesn't make sense since you need to have a valid Unix command after pipe not just the file name.
There is a file lets say List.txt and it contains the information of files which has to be copy from server to machine and then delete.
When shell scripts executes, it reads the List.txt file, store the files names in a variable, copy files from server to machine and then delete the server's files.
if file List.txt contains upto 16 file names then it's working fine.
in case of List.txt contains more than 16 files it gives error.
Error : too many arguments in input line
Any idea on it.
#Path of Log file
logdir="$HOME/log"
ftp="/usr/bin/ftp"
IP="192.168.1.199"
#User ID to login into remote server
user="tux"
#Password to login in remote server
pass="tux"
#Mention the path where the files will come in the current server
getlocaldir="/home/local/in"
#Mention the path where the FILEs are to FTP(get) in the remote server
getremotedir="/home/remote/out"
#Mention type of data transfer "asc" or "bin"
type="asc"
#date of FTP - Current date
dd=`date +%d`
# Creating a log file with datestamp
log="$logdir/wns_ft.log"
host=`hostname`
rc=0
boj=`date`
#current business date
BUSINESS_DATE=$HOME/file/businessdate
#==================
# Get Business Date
#==================
if [ ! -s $BUSINESS_DATE ]
then
echo -e "Get system date as the business date" >>$log
BDATE=`date +%y%m%d`
else
BDATE=`cut -c3-8 $BUSINESS_DATE` 2>>$log
fi
echo -e "Current business date: $BDATE" >>$log
#a text file contains the name of all file which has to be copied
bingoFileName=List.txt
dogetftp ()
{
LOCAL=$1
REMOTE=$2
echo "================================================"
echo "== Receiving Files From $IP =="
echo "================================================"
exec 4>&1
ftp -nv >&4 2>&1 |&
pid2=$!
print -p open $IP
print -p user $user $pass
print -p asc
print -p lcd $LOCAL
print -p cd $REMOTE
print -p pwd
print -p prompt
print -p mget $fileNamesListStr
print -p mdelete $fileNamesListStr $bingoFileName
print -p bye
wait $pid2
}
# method to get the bingo file containing plu-files-names to download
dogetbingo ()
{
LOCAL=$1
REMOTE=$2
echo "================================================"
echo "== Receiving Bingo file From $IP =="
echo "================================================"
exec 4>&1
ftp -nv >&4 2>&1 |&
pid2=$!
print -p open $IP
print -p user $user $pass
print -p asc
print -p lcd $LOCAL
print -p cd $REMOTE
print -p pwd
print -p prompt
print -p mget $bingoFileName
print -p bye
wait $pid2
}
# Method to read content of bingo file and creates file name string.
doreadBingo () {
echo "================================================"
echo "= Begin Reading Bingo File ="
echo "================================================"
LOCAL=$1
cd $LOCAL
if test -f $bingoFileName # Check if the bingo file exists
then
while read -r line
do
fileNamesListStr="$fileNamesListStr $line"
done < $bingoFileName
fi
echo "Files to download: $fileNamesListStr "
echo "================================================"
echo "= End Reading Bingo File ="
echo "================================================"
}
docheckget () {
LOCAL=$1
REMOTE=$2
DNLD_SUCCESS=`grep 'local: PLU' $log`
echo "SUCCESS: "$DNLD_SUCCESS
if [ "X$DNLD_SUCCESS" == "X" ]
then
NOT_FND_FILE_NAME="PLUNOTFOUND`date +%Y%m%d`.txt"
touch $LOCAL/$NOT_FND_FILE_NAME
echo "================================================"
echo "== Sending PLUNOTFOUND File to $IP =="
echo "================================================"
exec 4>&1
ftp -nv >&4 2>&1 |&
pid2=$!
print -p open $IP
print -p user $user $pass
print -p asc
print -p lcd $LOCAL
print -p cd $REMOTE
print -p pwd
print -p prompt
print -p put $NOT_FND_FILE_NAME
print -p bye
wait $pid2
rm $LOCAL/$NOT_FND_FILE_NAME
fi
}
case $1 in
mget)
#cd $localdir
exec 1>$log 2>&1
echo "---------------------------------------------------"
echo " Transfer bingo file "
echo "---------------------------------------------------"
dogetbingo $getlocaldir $getremotedir
echo "---------------------------------------------------"
echo " Read bingo file for file names to download "
echo "---------------------------------------------------"
doreadBingo $getlocaldir
echo "---------------------------------------------------"
echo " Begin FTP Session "
echo "---------------------------------------------------"
if [ "X$fileNamesListStr" != "X" ]
then
dogetftp $getlocaldir $getremotedir
docheckget $getlocaldir $getremotedir
else
echo "Nothing in Bingo file to download"
fi
echo "---------------------------------------------------"
echo " End FTP Session "
echo "---------------------------------------------------" ;;
esac
exit 0
I suspect this is a limitation with mget within your FTP client (or at the server end, possibly).
Best advice is to actually create one get line per file in $fileNamesListStr within the dogetftp() function.
For example:
dogetftp ()
{
LOCAL=$1
REMOTE=$2
echo "================================================"
echo "== Receiving Files From $IP =="
echo "================================================"
exec 4>&1
ftp -nv >&4 2>&1 |&
pid2=$!
print -p open $IP
print -p user $user $pass
print -p asc
print -p lcd $LOCAL
print -p cd $REMOTE
print -p pwd
print -p prompt
### Begin change here.
for fspec in $fileNamesListStr ; do
print -p get $fspec
print -p delete $fspec
done
print -p delete $bingoFileName
### End change here.
print -p bye
wait $pid2
}
I want to setup a cron job to rsync a remote system to a backup partition, something like:
bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root#remote1:/ /mnt/remote1/'
I would like to be able to "set it and forget it" but what if /mnt/remote1 becomes unmounted? (After a reboot or something) I'd like to error out if /mnt/remote1 isn't mounted, rather than filling up the local filesystem.
Edit:
Here is what I came up with for a script, cleanup improvements appreciated (especially for the empty then ... else, I couldn't leave them empty or bash errors)
#!/bin/bash
DATA=data
ERROR="0"
if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1\$"; then
ERROR=0
else
if mount /dev/vg/$1 /mnt/$1; then
ERROR=0
else
ERROR=$?
echo "Can't backup $1, /mnt/$1 could not be mounted: $ERROR"
fi
fi
if [ "$ERROR" = "0" ]; then
if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1/$DATA\$"; then
ERROR=0
else
if mount /dev/vg/$1$DATA /mnt/$1/data; then
ERROR=0
else
ERROR=$?
echo "Can't backup $1, /mnt/$1/data could not be mounted."
fi
fi
fi
if [ "$ERROR" = "0" ]; then
rsync -aqz --delete --numeric-ids --exclude=proc --exclude=sys \
root#$1.domain:/ /mnt/$1/
RETVAL=$?
echo "Backup of $1 completed, return value of rsync: $RETVAL"
fi
mountpoint seems to be the best solution to this: it returns 0 if a path is a mount point:
#!/bin/bash
if [[ `mountpoint -q /path` ]]; then
echo "filesystem mounted"
else
echo "filesystem not mounted"
fi
Found at LinuxQuestions.
if cut -d' ' -f2 /proc/mounts | grep '^/mnt/remote1$' >/dev/null; then
rsync -avz ...
fi
Get the list of mounted partitions from /proc/mounts, only match /mnt/remote1 (and if it is mounted, send grep's output to /dev/null), then run your rsync job.
Recent greps have a -q option that you can use instead of sending the output to /dev/null.
A quick google led me to this bash script that can check if a filesystem is mounted. It seems that grepping the output of df or mount is the way to go:
if df |grep -q '/mnt/mountpoint$'
then
echo "Found mount point, running task"
# Do some stuff
else
echo "Aborted because the disk is not mounted"
# Do some error correcting stuff
exit -1
fi
Copy and paste the script below to a file (e.g. backup.sh).
Make the script executable (e.g. chmod +x backup.sh)
Call the script as root with the format backup.sh [username (for rsync)] [backup source device] [backup source location] [backup target device] [backup target location]
!!!ATTENTION!!! Don't execute the script as root user without understanding the code!
I think there's nothing to explain. The code is straightforward and well documented.
#!/bin/bash
##
## COMMAND USAGE: backup.sh [username] [backup source device] [backup source location] [backup target device] [backup target location]
##
## for example: sudo /home/manu/bin/backup.sh "manu" "/media/disk1" "/media/disk1/." "/media/disk2" "/media/disk2"
##
##
## VARIABLES
##
# execute as user
USER="$1"
# Set source location
BACKUP_SOURCE_DEV="$2"
BACKUP_SOURCE="$3"
# Set target location
BACKUP_TARGET_DEV="$4"
BACKUP_TARGET="$5"
# Log file
LOG_FILE="/var/log/backup_script.log"
##
## SCRIPT
##
function end() {
echo -e "###########################################################################\
#########################################################################\n\n" >> "$LOG_FILE"
exit $1
}
# Check that the log file exists
if [ ! -e "$LOG_FILE" ]; then
touch "$LOG_FILE"
chown $USER "$LOG_FILE"
fi
# Check if backup source device is mounted
if ! mountpoint "$BACKUP_SOURCE_DEV"; then
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Backup source device is not mounted!" >> "$LOG_FILE"
end 1
fi
# Check that source dir exists and is readable.
if [ ! -r "$BACKUP_SOURCE" ]; then
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to read source dir." >> "$LOG_FILE"
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync." >> "$LOG_FILE"
end 1
fi
# Check that target dir exists and is writable.
if [ ! -w "$BACKUP_TARGET" ]; then
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to write to target dir." >> "$LOG_FILE"
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync." >> "$LOG_FILE"
end 1
fi
# Check if the drive is mounted
if ! mountpoint "$BACKUP_TARGET_DEV"; then
echo "$(date "+%Y-%m-%d %k:%M:%S") - WARNING: Backup device needs mounting!" >> "$LOG_FILE"
# If not, mount the drive
if mount "$BACKUP_TARGET_DEV" > /dev/null 2>&1 || /bin/false; then
echo "$(date "+%Y-%m-%d %k:%M:%S") - Backup device mounted." >> "$LOG_FILE"
else
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to mount backup device." >> "$LOG_FILE"
echo "$(date "+%Y-%m-%d %k:%M:%S") - ERROR: Unable to sync." >> "$LOG_FILE"
end 1
fi
fi
# Start entry in the log
echo "$(date "+%Y-%m-%d %k:%M:%S") - Sync started." >> "$LOG_FILE"
# Start sync
su -c "rsync -ayhEAX --progress --delete-after --inplace --compress-level=0 --log-file=\"$LOG_FILE\" \"$BACKUP_SOURCE\" \"$BACKUP_TARGET\"" $USER
echo "" >> "$LOG_FILE"
# Unmount the drive so it does not accidentally get damaged or wiped
if umount "$BACKUP_TARGET_DEV" > /dev/null 2>&1 || /bin/false; then
echo "$(date "+%Y-%m-%d %k:%M:%S") - Backup device unmounted." >> "$LOG_FILE"
else
echo "$(date "+%Y-%m-%d %k:%M:%S") - WARNING: Backup device could not be unmounted." >> "$LOG_FILE"
fi
# Exit successfully
end 0
I am skimming This but I would think you would rather rsync -e ssh and setup the keys to accept the account.