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/

Related Posts

  • 39
    This script use to transfer file from linux to ftp server. You can automate this file transfer by putting this file in cronjob also. #!/bin/sh HOST='ftp.users.qwest.net' USER='yourid' PASSWD='yourpw' FILE='file.txt' ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE quit END_SCRIPT exit 0  Please note that : Using…
    Tags: ftp, file, user, linux, server, script, shell
  • 30
    The vi Editor http://t4test.com/blog/unix-linux-shell-script-introduction-to-shell-scripting/ http://t4test.com/blog/read-making-shell-script-interactive/ http://t4test.com/blog/cpio-a-backup-program/ Backup Using TAR Backing up your files using tar is very simple you just type a little command. tar -cvpzf /BackupDirectory/backupfilename.tar.gz /ImportantData/directory/path Let’s suppose i have directory called /imp-data on root and i want to make backup of this directory including sub directories on…
    Tags: file, crontab, will, linux, shell, script

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

Your email address will not be published. Required fields are marked *

%d bloggers like this: