Linux Shell Script To Ftp File To Server

You need to create a shell scrip, needed to call from a crontab, to contact a FTP server and put or
get a file.

You will need to modify the variable section to reflect your settings.

—————————————-

#!/bin/bash

HOST=ftp.server.com  #This is the FTP servers host or IP address.
USER=ftpuser             #This is the FTP user that has access to the server.
PASS=password          #This is the password for the FTP user.

# Uses the ftp command with the -inv switches.  -i turns off interactive prompting. – Restrains FTP from attempting the auto-login feature. -v enables verbose and progress.

ftp -inv $HOST << EOF #  Here the login credentials are supplied by calling the variables. user $USER $PASS #  Here you will change to the directory where you want to put or get cd /path/to/file #  Here you will tell FTP to put or get the file. put test.txt Or get test.txt bye EOF ---------------------------------- Now you will need to make this script executable and call it from crontab.

#chmod +x ftpscript.sh

#crontab -e

0 1 * * * /path/to/script/ftpscript.sh

For more information to cron job schedule, Follow the below link.

http://blog.eduguru.in/linux-cron-job-schedule-job-in-linux-crontab/

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply