ftp upload in one command

Posted by caike on March 04, 2010

As part of a backup routine, I had to upload a file to an ftp server. It actually took me some time to figure out how to do this with one command, so I thought I’d post it here:

curl -sS -T ${FILE_PATH}/${FILE_NAME} --ftp-pasv \
ftp://${FTP_USER}:${FTP_PWD}@${FTP_URL}/${FILE_NAME}

This example is uploading the file to the ftp server using silent mode (-s) and showing errors when they occur (-S), while connecting to the server in passive mode (–ftp-pasv).