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
#!/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
0 comments:
Post a Comment