automating ftp transfer using script file

Associate
Joined
6 Nov 2006
Posts
722
Location
Devon
Hi

I have a lot of files that I need to get from an ftp server so I'm trying to automate the process but I'm haveing a bit of trouble with the authentication. My script is
Code:
#!/bin/bash


echo "enter year ?"
read year
echo "enter month ?"
read month
export LOGNAME=mylogname
echo bin > in
for i in $(seq -w 01 31); do
	echo cd /badc/ecmwf-e40/data/gg/ap/$year/$month/$i >> in
	echo get ggap${year}${month}${i}00pv.grb >> in
	echo get ggap${year}${month}${i}06pv.grb >> in
	echo get ggap${year}${month}${i}12pv.grb >> in
	echo get ggap${year}${month}${i}18pv.grb >> in
done
echo bye >> in
cat in
ftp ftp.badc.rl.ac.uk < in

when I run it I get the following output
Code:
AUTH not understood
AUTH not understood
KERBEROS_V4 rejected as an authentication type
Password:Name (ftp.badc.rl.ac.uk:mylogname):
and when I type my password I get lots of messages saying Please logine using USER and PASS.

If anyone could help me get the authentication working I would be very grateful.

Thanks
 
You could put your username and password in a .netrc file to log you in automatically - see the .netrc file section in the man page of the ftp command itself.
 
I've just tried that and it logs in fine if I manually ftp now but when I run the script it seems to hang for a while after
Code:
AUTH not understood
AUTH not understood
KERBEROS_V4 rejected as an authentication type
then just quits the script without downloading any of the files or giving any error messages
 
I've seen that Kerberos error before, IIRC it means your ftp binary is actually /usr/kerberos/bin/ftp - try changing the ftp command in your script to /usr/bin/ftp instead, and maybe try with -v and capturing the output to see if you can spot anything obvious.
 
Back
Top Bottom