FTP using list of commands in a text file

less than 1 minute read

Typing out ftp commands each time is error prone and no fun. Here’s an easy way to list all the commands in a text file and supply them sequentially to the ftp command.

ftp -s:ftpcommands.txt

Here’s a sample ftpcommands.txt file:

open
servername
username
password
prompt
cd /path/to/folder
ls
close
bye

The prompt in there turns off prompt mode so commands such as mput or mget aren’t stuck waiting for user confirmation.

Transmitting non-text files

There are two modes of file transfer.

  1. ASCII- this only works for text because it assumes everything in the file can be encoded using ASCII characters
  2. Binary- uses more bytes to transfer but works for any type of files.

Leave a Comment