You are here

Add new comment

FTP in shell script

I have mainly used a GUI based FTP program (gftp), but while debugging my website I find it more effective to use FTP in a shell script.

The script I use takes one argument: the file to be transferred.

#! /bin/sh
echo -use a "here" document to embed ftp commands in the script
# Begin of "here" document
ftp <<**
open ftp_site
cd the_target_directory
lcd /.../the_local_source_directory
put $1
bye
# End of "here" document
echo ftp transfer ended

The settings of username, password and destination ftp site must be in the .netrc file in the home directory. The format is as follows:

machine your_ftp_site login your_login password your_passwd

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer