Showing posts with label shell script to FTP multiple files. Show all posts
Showing posts with label shell script to FTP multiple files. Show all posts

Thursday, May 12, 2011

Shell script that FTP multiple files whose creation time is last 60 minutes

Sometimes you need to write a shell script which can FTP files(specific types) whose creation time is for example in last one hour. I've written following shell script which does the same. I hope it will help you.


#!/bin/bash
cd /opt/archive/
movedFile=`find . '*.csv' -cmin -60 `
HOST=192.168.0.15
USER='user'
PASSWD='xxxx'
for i in $movedFile; do
        echo "Uploading file $i ...."
        /usr/bin/ftp -n $HOST <         quote USER $USER
        quote PASS $PASSWD
        binary
        cd Records
       put $i
       quit
END_SCRIPT
mv $i /root/backup/
done