Reputation: 344
I'm trying to download some files using a batch file, however after reading the username line an error is thrown 'Invalid command'.
In my batch file I call my ftp file as follows:
ftp -n -s:ftp_download.txt
my ftp_download.txt looks like this:
open myname.com
[email protected]
test
lcd C:\myDownloads
cd download_files
get MY_NEW_FILES_*.xml
bye
However after the [email protected]
line an error is thrown 'Invalid command' and thus the script does not connect to my ftp server.
When authenticating as follows:
open myname.com
user [email protected] test
I get the 'not connected' error
However using this username ([email protected]) and password (test) I'm still able to connect using Filezilla .
Am I missing a command somewhere?
Upvotes: 0
Views: 4502
Reputation: 344
To those, like CharlesKSQL, who might stumble upon my question. Here's how I got it to work (it turned out I had to use sftp for some reason so make sure it's enabled on your server);
The script (ftp_download.txt) contains the following:
option batch abort
option confirm off
open sftp://<username>:<password>@<host> -hostkey="<fingerprint/key>"
option transfer binary
cd <your folder>
get <some file>
If you do not know the fingerprint and/or key; you can find these in FileZilla when connecting trough sftp. They are shown in the popup that show up when you connect to your server for the first time or you could click the little lock-icon in the statusbar on the bottom right when you are connected already.
Now to actually connect you'll need a little bit of software (when using Windows) to create the secure connection. I used WinSCP. You can download the portable executables here and place them (for easy usage) in the same folder as your batch file. Then you can call the executable in your batch file by adding a parameter:
winscp.exe /script=ftp_download.txt
which should then execute your download script.
P.S.: it's been a while since I finished this, it's still working as far as I know.
Upvotes: 1
Reputation: 2644
Your text file should look like this:
open myname.com
user
<enter username here> <password here>
lcd C:\myDownloads
cd download_files
get MY_NEW_FILES_*.xml
bye
Try that and see if it helps
Upvotes: 0