I'm running on a Linux machine and can't get FTP uploads working. Here's my script:
HOST='ftp.name.com'
USER='username'
PASSWD='mypwd'
FILE='f1020811'
DIR='/data_dir/send'
echo **************************************************************
echo * Attempting FTP *
echo **************************************************************
ftp -n -u -d ftp.name.com <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put f1020811
END_SCRIPT

I noticed using $HOST was rejected. Replacing it with the actual ftp name worked. The script successfully logged on to the host, BUT the put failed with the message "no such file or directory". The file is in the current directory. Should there be a path-name?

Is there a reason to use ftp specifically?

Linux has scp (Secure Copy) which like ssh uses encrypted traffic to move files between servers. The following web site has a great explanation of using scp and tells you how to set up the servers with rsa keys so that no password is needed for a specific user on each system to be able to transfer files and even gives sample shell scripts.

http://www.linuxjournal.com/article/8600

This doesn't look like a solution since I have to copy from our Linux box to an IBM iSeries. But thanks for the thought.
John

Ok well in that case try this instead.

#!/bin/sh
HOST='ftp.users.qwest.net'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0

Thanks. I found this to work:
#!/bin/sh
USER=username
PASSWD=PSWD
ftp -n -v -d ftp.placecom <<SCRIPT
user $USER $PASSWD
cd /directory/data-dir
binary
put filename
quit
SCRIPT

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.