Bash Script to create automatic FTP session and download file

This script automatically opens a FTP session and downloads file to local disk. Here is the scenario:

ftp: myftp.ext

username: myusername

password: mypassword

file to download: myfile.txt

1) Create bash script automatic_ftp_download.sh:

#!/bin/bash
# Script to create automatic FTP session and download file

ftp -n myftp.ext << end
us myusername mypassword
get myfile.txt
bye
end

2) make automatic_ftp_download.sh script executable:

chmod +x automatic_ftp_download.sh

3) run automatic_ftp_download.sh scrip:

./automatic_ftp_download.sh

4) find myfile.txt on your local disk

Leave a Reply

You must be logged in to post a comment.