This is my script. As you can see it executes only 1 command (cd /) after connecting to a remote FTP server. It's very simple… but it doesn't work and give me "Invalid command".
I don't understand why.
#!/bin/bash
HOST=xxx #This is the FTP servers host or IP address.
USER=xxx #This is the FTP user that has access to the server.
PASS=xxx #This is the password for the FTP user.
# Call 1. Uses the ftp command with the -inv switches.
#-i turns off interactive prompting.
#-n Restrains FTP from attempting the auto-login feature.
#-v enables verbose and progress.
ftp -inv $HOST << EOF
# Call 2. Here the login credentials are supplied by calling the variables.
user $USER $PASS
pass
# Call 3. I change to the directory where I want to put or get
cd /
# Call4. Here I will tell FTP to put or get the file.
#put...
# End FTP Connection
bye
EOF
This is the output:
Connected to [IP]
220 Microsoft FTP Service
?Invalid command
331 Password required for logweb.
230 User logged in.
Remote system type is Windows_NT.
Passive mode on.
?Invalid command
250 CWD command successful.
?Invalid command
?Invalid command
?Invalid command
221 Goodbye.
Best Answer
The "Invalid command" error is due to those
#
lines. Theftp
does not recognize the#
as a comment prefix.If you need the comments in the script, you can abuse an escape to shell command
!
and follow that by a shell comment:Other than that, I believe all commands in your script are executed, despite your claim that only one is: