sent file in ftp using a bash script

Below the script.

#!/bin/sh

# Parametres: host FTP Server
# user FTP Username
# passwd FTP Password
# file File to send/put
############################################################################

# Variables
HOST=$1
USER=$2
PASSWD=$3
FILE=$4
TONAME=$5

# Connect to FTP HOST and Send File
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
dir
ascii
put $FILE $TONAME
dir
quit
END_SCRIPT
exit 0

####fin

The command line would be:
./ftpscript <host> <username> <passwd> <filename> <toname>
exemple:

./ftpscript 192.168.1.xx joe mypassword /var/log/messages /upload/messages.txt

Leave a Reply