Results 1 to 2 of 2
Hi, this is my first post. I'm trying to write a simple script to upload multiple files to my incoming directory on my work's ftp server. I think I've got ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-28-2006 #1
Having trouble with simple batch ftp script (bash)
Hi, this is my first post. I'm trying to write a simple script to upload multiple files to my incoming directory on my work's ftp server. I think I've got most of it correct, as I've transferred individual files with the script. I tried to use a while loop to iterate through each positional parameter on the command line that corresponds to a file to be transferred:
#! /bin/sh SCRIPT=`basename $0` if [ -z "$1" ] ; then echo "$SCRIPT: Usage: `basename $0` File-one File-two File-three" exit 1 fi SERVER=server_name_goes_here DIRECTORY=incoming_directory_goes_here PASSWORD="my_email_address" echo -e "\nBeginning ftp transfer...\n" while [ -n "$1" ] ; do FILENAME=`basename $1` ftp -n $SERVER <<End-of-Session user anonymous "$PASSWORD" binary bell cd $DIRECTORY pwd put "$FILENAME" ls bye End-of-Session shift done echo -e "\nftp session ended..." exit 0
"ftp.sh: line 35: syntax error: unexpected end of file"
Is my shift command misplaced, perhaps?
- 03-05-2006 #2
- Join Date
- Mar 2006
The only problem I see is that your second "End-Of-Session" should be at the start of its line, with no leading whitespace (at least, going by the behavior of my system's GNU bash 3.0). However, I'm not sure how you got this to work for single-file transfers...