Linux.com

Home Linux Community Community Blogs Personal FTP file transfer with an automated bash script

FTP file transfer with an automated bash script

This is a really quick blog post, I don't wanna bother you with a complete article related to FTP, this morning I've had to automate a batch job, this job needs to transfer local data to a remote FTP server here's what I've done:

#!/bin/bash
HOST='your.ftp.site'
USER='remoteusername'
PASSWD='remotepasswd'

ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd upload
ls -la
bye
EOT

The script automatically connects to a remote server "your.ftp.site" with a defined username/password pair (remoteusername, remotepasswd) and execute some commands in the middle, in my case :

cd upload
ls -la

but of course you can customize with your own commands

This is not a tech article and not even something cool, just useful as a quick tip for a newbie, hope it helps..

 

Ben

 

Comments

Subscribe to Comments Feed
  • Kalpana Said:

    Thanks for the script. Its simple and easy to use

  • Ken Diebel Said:

    Hello all, I have my user name and passsword for an FTP site that I want to access for information that is available to me to use from an FTP site .My goal is to access the FTP site at different times throughout the day and get specific tiime specific information and then pull it off the FTP site and store it at a specific location on my automation system and then play it back at specified times that I program on my automation system. Any help is appreciated.. Thank you.

  • Benjamin Said:

    I was trying to do this exact thing, and it's the -n flag that was missing. Thanks for this!

Upcoming Linux Foundation Courses

  1. LFS230 Linux Network Management
    06 Oct » 09 Oct - Virtual
    Details
  2. LFD331 Developing Linux Device Drivers
    13 Oct » 17 Oct - Virtual
    Details
  3. LFS430 Linux Enterprise Automation
    13 Oct » 16 Oct - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board