Bash – FTP multiple file

Do you need to transfer multiple file automatically ?

try this script :


#!/bin/bash
HOST="hostname_destination"
USER="username"
PASS="password"
#getting current date for checking filename
a=`date '+%Y%m%d'`;
#checking if directory exist or not
if [ -d /home/mmsc2/mms_home/cdr/ ]
then
cd /home/mmsc2/mms_home/cdr/stat/send/
ftp -inv $HOST
user $USER $PASS
#enable passive mode
epsv
mput *$a*
bye
EOF
fi

Save it as ftptransfer.sh

set the permission :

chmod +x ftptransfer.sh

Then add a crontab by doing :

host#crontab -e
59 23 * * * ftptransfer.sh

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s