FTP via BASH

in this morning, i’ve make a simple script for copying files from server A to server B. When i try to use sshles password, my remote-server always asked me a password. i’ve give up configuring sshless password between server A to server B, so i try to use FTP. little bit tricky i think, but this is only the way. Here’s the simple script for uploading file via FTP in bash :

HOST=xxxx
USER=yyyyy
PASS=zzzzzz
cd /backup/backup/db/
pwd
ls -lash
ftp -inv $HOST << EOF

# Call 2. Here the login credentials are supplied by calling the variables.

user $USER $PASS

# change to the FTP directory where you want to put or get
cd /tmp

# Upload A file to FTP server using put

put uji_coba-`date +%Y-%m-%d`.ypt
# or downloading file from ftp server
# get uji_coba-`date +%Y-%m-%d`.ypt
bye
EOF

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s