There is some method for auto login ftp like .netrc,macros but here I have written simple scripts for ftp auto login.
Steps
Following steps are required to write shell script:
(1) Use any editor like vim or mcedit to write shell script.
(2) After writing shell script set execute permission for your script as follows
syntax:
chmod permission your-script-name
Examples:$ chmod +x your-script-name
$ chmod 755 your-script-name
#!/bin/bash
ftp_site="192.168.2.130"
username=user
passwd=password
ftp -in <
user $username $passwd
bin
put test >> For testing I have put the test file into ftp server
close
bye
EOF
Backup
#!/bin/bash
ftp_site=ftp://ftpyoursite.com
username=user
passwd=password
backupdir=$HOME
filename="backup-$(date '+%F-%H%M').tar.gz"
echo "Creating a backup file $filename of $backupdir."
# Make a tar gzipped backup file
tar -cvzf "$filename" "$backupdir"
ftp -in << eof
open $ftp_site
user $username $passwd
bin
put $filename
close
bye
EOF
No comments:
Post a Comment