Search code examples
linuxbashshellftpsuse

FTP Script to move files from Suse server to ftp


We need to move all the files from particular folder to ftp server. We wrote a script but getting directory not found exception. Below is the script.

#!/bin/sh
HOST='192.168.1.100'
USER='ramesh'
PASSWD='rameshftp'
ftp -inv $HOST << EOF
user $USER $PASSWD
cd /home/Ramesh
put *.zip
bye
EOF

Our requirement is to copy all the files which resides in some directory in Suse Linux Server and copy to FTP server. for eg: Copy all the contents from "/home/Ramesh" directory and put into ftp server.


Solution

  • You can do this in one line with ncftp:

    ncftpput -u username -p password ftp-host-name /path/to/remote/dir /path/to/local/dir/*
    

    See http://linux.die.net/man/1/ncftp for more info