Install ncftp client
sudo apt-get install ncftp
yum install ncftp
ncftpput ftp-host-name /path/to/remote/dir /path/to/local/dir
ncftpput -options ftp-host-name /path/to/remote/dir /path/to/local/dir
You can pass the password with -p option:
ncftpput -R -v -u “username” -p “passwordHere” ftp.nixcraft.biz /nixcraft/forum /tmp/phpbb
You can use port number 2021 instead of the default FTP service port # 21 as follows:
ncftpput -R -v -u “username” -p “passwordHere” -P 2021 ftp.nixcraft.biz /nixcraft/forum /tmp/phpbb
#!/bin/bash
# Shell script to copy all files recursively and upload them to
# remote FTP server (copy local all directories/tree to remote ftp server)
#
# If you want to use this script in cron then make sure you have
# file pointed by $AUTHFILE (see below) and add lines to it:
# host ftp.mycorp.com
# user myftpuser
# pass mypassword
#
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2005 nixCraft
# Feedback/comment/suggestions : http://cyberciti.biz/fb/
# ————————————————————————-
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ————————————————————————-
FTP=”/usr/bin/ncftpput”
CMD=””
AUTHFILE=”/root/.myupload”
if [ -f $AUTHFILE ] ; then
# use the file for auth
CMD=”$FTP -m -R -f $AUTHFILE $myf $remotedir $localdir”
else
echo “*** To terminate at any point hit [ CTRL + C ] ***”
read -p “Enter ftpserver name : ” myf
read -p “Enter ftp username : ” myu
read -s -p “Enter ftp password : ” myp
echo “”
read -p “Enter ftp remote directory [/] : ” remotedir
read -p “Enter local directory to upload path [.] : ” localdir
[ "$remotedir" == "" ] && remotedir=”/” || :
[ "$localdir" == "" ] && localdir=”.” || :
CMD=”$FTP -m -R -u $myu -p $myp $myf $remotedir $localdir”
fi
$CMD
credit to:
http://bash.cyberciti.biz/backup/copy-all-local-files-to-remote-ftp-server-2/
http://baptiste-wicht.com/posts/2011/06/upload-files-to-ftp-using-bash.html