Web Hosting Talk







View Full Version : shell scripting redirection question


EthicalEpi
07-11-2005, 08:06 AM
ftp -v -n $Host << FTPSCRIPT
user $Username $Password
cd somedir
delete somefile.txt
bye
FTPSCRIPT

echo "completed..."

the above is a simplified snippet from a shell script that I'm working on at the moment. It basically logs into an FTP account, changes directory, then deletes a file and exits. This works OK.

The problem I'm having is that it never gets to the echo "completed..." line and doesn't continue with the rest of the script.

Anyone have any ideas why that is? I've got a feeling this is something very simple that I'm missing to do with the redirection but haven't been able to find an explanation online. I'm pretty new to shell scripting.

EthicalEpi
07-11-2005, 10:45 AM
Never mind. Figured it out eventually. As my code is indented to keep it nice and tidy (which you don't see in the snippet above), the FTPSCRIPT line was indented with a tab, where it needs to be at the start of a new line for it to be recognised as the closing string. Doh!