Please can you help, I�ve wrote the following script on a
solaris 10
server to transfer files to a windows machine.
#!/usr/bin/sh
cd /moneta_polled01/download
HOST=10.100.4.72
USER=user1
PASSWD=V7stop
/usr/bin/ftp -v $HOST <<EOF
user $USER $PASSWD
cd tmp
binary
put test.txt
bye
EOF
but when I run it, I got the following:
./get_sdp.sh
Connected to 10.100.4.72.
220-FileZilla Server version 0.9.49 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit https://filezilla-project.org/
Name (10.100.4.72:root): 331 Password required for user user1 v7st
Password:
530 Login or password incorrect!
Login failed.
Remote system type is UNIX.
530 Please log in with USER and PASS first.
530 Please log in with USER and PASS first.
530 Please log in with USER and PASS first.
530 Please log in with USER and PASS first.
221 Goodbye
Please can you tell me if there is anything wrong with the script
Well, without wishing to be cruel, it looks like your credentials are wrong. Can you do this interactively before we try to automate it?
I've fallen over this myself as we have Windows domains to consider. If the account you are trying to connect to is a domain wide account rather than an account local to the server, you need to qualify it. You might try variations like this for your USER value:-
The extra \ characters are because the / & \ may be getting interpreted by your shell script and when they are fed into the actual ftp it's getting lost.
I've had different variations for different target servers. No idea why the variation.
Looking again closely at your output, the prompt being sent is 331 Password required for user user1 v7st which also suggests that you might need to break the input, so instead of user $USER $PASSWD you might need:-
I�ve tried all the options all the options you suggested but did not work, and all of them prompt me for a password, and if you look closely, the first letter of PASSWD=V7stop , in one of the lines converts the first letter of the password to small caps
I had not noticed that either. Is the variable PASSWD defined elsewhere as a lower-case string with a typeset -l command, perhaps in the calling script or environment.
Can you embed:-
PASSWD=V7stop
ROBIN=V7stop
printf "PASSWD is $PASSWD \n"
printf "ROBIN is $ROBIN \n"
.... and see if that illustrates where the problem might be.
./test_sdp.sh
PASSWD is V7st
Connected to 10.100.4.72.
220-FileZilla Server version 0.9.49 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit https://filezilla-project.org/
Remote system type is UNIX.
331 Password required for user1
530 Login or password incorrect!
Login failed.
530 Please log in with USER and PASS first.
?Invalid command
530 Please log in with USER and PASS first.
530 Please log in with USER and PASS first.
530 Please log in with USER and PASS first.
221 Goodbye
root@moneta #
As you can see, the first line after script name, the
password
is not correct, the correct
password
is "V7stop" and not "V7st". But on the script is set correctly