Hi guys, the following scripts you can use to upload and download directories from your ftp server using lftp.
1. Upload Script
#!/bin/bash
### Defining Path
dir1="/source/path"
dir2="/destination/path"
user="ftp-username"
pass="password"
### Upload command
lftp -e "mirror -R $dir1 $dir2 ;quit" -u $user,$pass yourdomain.com
#### Checking upload failure/success
if [ $? -eq 0 ]
then
echo "Download Successful"
exit 0;
else
echo "Download Not Successful"
exit 1;
fi
####
1. Upload Script
#!/bin/bash
### Defining Path
dir1="/source/path"
dir2="/destination/path"
user="ftp-username"
pass="password"
### Upload command
lftp -e "mirror -R $dir1 $dir2 ;quit" -u $user,$pass yourdomain.com
#### Checking upload failure/success
if [ $? -eq 0 ]
then
echo "Download Successful"
exit 0;
else
echo "Download Not Successful"
exit 1;
fi
####
2. Download Script
In above script change this command
lftp -e "mirror -R $dir1 $dir2 ;quit" -u $user,$pass yourdomain.com
to
Note: You can pass source and destination path (parameters) from command
line as run time argument. For this replace source and destination path
with $1 and $2 and run your script like below -
sh filename.sh source destination
]
If you have any queries and difficulties, please comment.
Thanks
No comments:
Post a Comment