Search code examples
linuxshellftp

Execute FTP command file in Linux


As described in the title, I want to login in the ftp server and run a local FTP command file with ftp commands, in one single command that will be executed through php. I have done this in the past but with sftp but not with ftp.

I want to achieve something like the following that I have done for sftp:

sftp -b commands.txt user@host

The commands.txt file contains the ftp commands to be run in the server (e.g mget)


Solution

  • Common Linux ftp does not have any option to provide a script file.

    But you can use a standard input redirection instead:

    ftp < commands.txt