• Home
  • LinuxBash
  • Pushing a file via ftp and the bash command line to an ftp server

Pushing a file via ftp and the bash command line to an ftp server

Since I work with the XDA server, I often have to work on stuff in the XDA server, finish it and upload it to my host. Now Goo.im conveniently offers a sftp access, that makes everything very easy. A simple scp command can transfer the file (already descibed elsewhere on my blog). However when it comes to transferring the files via simple ftp, things are a bit different. You need a bash scrip to do it.

I’ve used this script from  Ubuntuforums to suit my needs perfectly:

# The next 9 lines are lifted from mickwombat's script
#!/bin/sh
USERNAME="[email protected]"
PASSWORD="myftppassword"
SERVER="ftp.droidzone.in"
# Directory where file is located
DIR=$2
#  Filename of backup file to be transfered
FILE=$1
# login to ftp server and transfer file

curl -T $FILE -u $USERNAME:$PASSWORD $SERVER/$DIR/

This very neatly takes the file specified in the first argument, and transfers it to ftp.droidzone.in/dir where dir is the specified directory.