Usually, ftp
command line clients support the configuration file ~/.netrc
where you can configure credentials for remote systems, e.g.:
machine legacy.system.example.org
login juser
password keins
When you ftp legacy.system.example.org
then you don't have to retype this information anymore.
If you need to do more automation, you can script ftp
via piping commands into it, e.g.:
$ cat pushit.sh
# complex logic to set
# EXAMPLE_FILE=
ftp <<EOF
prompt
mput $EXAMPLE_FILE
quit
EOF
Sure, if the system does not support ssh
, it probably does not support ftps either - but you can try it (e.g. via ftp-ssl) if you need to secure your connection.
LFTP
An alternative to one of the plain ftp
commands is to use lftp
, since it provides several features to automated login and command execution.
Example:
$ lftp -e 'source ~/login.lftp'
$ cat login.lftp
open sftp://juser:geheim@backup.example.net
cd /path/to/favorite/dir
Note that this example shows automated password authentication to a SFTP server which is not supported by the standard OpenSSH sftp client.
The option -e
instructs lftp to execute the commands at startup and stay interactive.
Of course, such a lftp script mach also source other scripts, and also automatically disconnect from the server.
In contrast, with -c
or -f
lftp directly exits after executing the commands specified as argument or read from the specified file.
Best Answer
I always use the
lftp
client which has the ability to resume a download that either died midstream or that I want to cancel and later restart.I usually use the command like so:
What else?
This tool's name is a bit misleading, it can handle either FTP or SFTP.
ftp
sftp
Mirroring Links
From time to time you might encounter a issue with mirroring directories that contain symlinks, to work around this issue you can add this option to your
lftp
command:For eg:
References