Hi,
I'm going to show how to send files (backup copies for example) via FTP using ncftp and a traditiona ftp cliente under linux.
And now the script (script name: sendviaftp.sh) :
where $1 is the command line parameter. For example:
1) Add to the file ~/.netrc the user and password for your FTP
I'm going to show how to send files (backup copies for example) via FTP using ncftp and a traditiona ftp cliente under linux.
NCFTP
First we need to install the ncftp package:apt-get insttall ncftp
And now the script (script name: sendviaftp.sh) :
#!/bin/bash
FTP_SERV="ftp.yourserver.com"
FTP_USER="youruser"
FTP_PASS="yourpass"
FTP_PATH="/directory/you/want"
ncftpput -R -m -u $FTP_USER - p $FTP_USER $FTP_SERV $FTP_PATH $1
where $1 is the command line parameter. For example:
./sendviaftp.sh filetosend.tar.gz
FTP Cliente
If you want to do the same with your traditional FTP client the steps are:1) Add to the file ~/.netrc the user and password for your FTP
vi ~/.netrc
default login FTPUSERNAME password FTPPASSWORD
2) Write the next script
3) Try it up:
#!/bin/bash
HOST='ftp.yourserver .com'
ftp -i $HOST <<END_SCRIPT
put $1
quit
END_SCRIPT
exit 0
3) Try it up:
chmod 0600 ~/.netrc
chmod +x ftpscript
./ftpscript
Bye!
No comments:
Post a Comment