Bash FTP Scripting
Creating a Bash FTP Script and installing as a cronjob can be a great way to move files around at scheduled intervals .
#!/bin/bash#pull and push from FTP SERVER#change to the ftp_in directory
cd /home/user/ftp_inftp -niv ftp.address.to.connect.to << FTP_COMMAND
user username password
cd To_pvlogistics
mget *
mdel *
bye
FTP_COMMAND#Change to the ftp_out directory
cd /home/user/ftp_outftp -niv ftp.address.to.connect.to << FTP_COMMAND
user username password
mput *.*
bye
FTP_COMMANDmv * /home/user/ftp_sentSaving an example of this script in a file called /home/user/ftp-script.sh it can be installed as a cronjob to run every X minutes as below. In this example it is set to run every 10 minutes.
*/10 * * * * /home/user/ftp-script.shFTP man pages for further reading and information on standard FTP commands and usage examples:
FTP
File Transfer ProtocolSyntax
FTP [-options] [-s:filename] [-w:buffer] [host]
Key
-s:filename Run a text file containing FTP commands.
host Host name or IP address of the remote host.
-g Disable filename wildcards.
-n No auto-login.
-i No interactive prompts during ftp.
-v Hide remote server responses.
-w:buffer Set buffer size to buffer
(default=4096)
-d Debug
-a Use any local interface when binding data connection.
http://ss64.com/bash/ftp.html

No comments:
Post a Comment