Friday, August 17, 2018

Bash Script Transfer files through FTP from within script

Bash Script Transfer files through FTP from within script


Below shell script demonstrate the usage of FTP operation from within the bash script, feel free to copy and use this script:

Source: cat autoftp.sh
#!/bin/bash

if [ $# -ne 1 ]; then
        echo "Please provide the file path for ftp operation."
        exit
fi

USERNAME=linuxpoison
PASSWORD=password
FILENAME="$1"
FTP_SERVER=ftp.foo.com
echo "Starting the ftp operation ...."

ftp -n $FTP_SERVER <<Done-ftp
user $USERNAME $PASSWORD
binary
put "$FILENAME"
bye
Done-ftp

echo "Done with the transfer of file: $FILENAME"
exit

Output: ./autoftp.sh log.tar.gz
Starting the ftp operation ....
Done with the transfer of file: log.tar.gz




visit link download

No comments:

Post a Comment