Is there a way to shebang-ify ftp and write small ftp scripts?For example:#!/usr/bin/ftpopen 192.168.1.1put *.gzquitAny thoughts?
ftp and shebang
shell;shell script;ftp
Not with the ftp programs I've run into, as they expect a script on their standard input but a shebang would pass the script name on their command line.You can use a here document to pass a script to ftp through a shell wrapper.#!/bin/shftp <<EOFopen 192.168.1.1put *.gzEOFLftp accepts a script name passed as an argument.#!/usr/bin/lftp -fopen 192.168.1.1put *.gzNcftp comes with two tools ncftpget and ncftpput for simple batches of gets or puts.Zsh includes an FTP module. Using a proper shell rather than a straight FTP script has the advantage that you can react to failures.#!/bin/zshzmodload zsh/zftpopen 192.168.1.1put *.gzOf course there are plenty of other languages you could use: Perl, Python, Ruby, etc.Another approach is to mount the FTP server as a directory, and then use cp (or rsync or other tools) to copy files. There are many FUSE filesystems for FTP access, principally CurlFtpFS and LftpFS.Note that if you were planning to use authentication (likely if you're uploading), and you have control over the server, you'd be better off with SSH access. It's more secure and more flexible. To copy files over SSH, you can use scp or sftp, or rsync for efficient synchronization (if some of the files may already be there), or Unison (for bidirectional synchronization), or mount with SshFS.