I've created a script to download a file from an FTP server using VBA to fire off the script. I can connect to the server and navigate to the correct directory, but when I got to get the file I get the message:
500 Port command invalid
I've tweaked the code as much as I can but I don't understand enough about ports or FTP to know what I need to change.
The VBA code:
Dim FTPcommand As String
Dim wsh As Object
FTPcommand = "ftp -n -s:" & Chr(34) & "C:\path\to\FTP_commands.txt" & Chr(34)
Set wsh = CreateObject("WScript.Shell")
wsh.Run FTPcommand, 5, True
The script:
open ftp.blahblahbah.bl
user username password
lcd C:\Users\me\Documents\location
cd /specific location/
get "file.xlsx"
I expect the file to download but get the following messages (after the script logs in and successfully navigates to the filepath):
ftp> open ftp.address.com
Connected to ftp.address.com
220 Welcome to address.com
ftp> user USERNAME PASSWORD
---> USER USERNAME
331 User USERNAME, password please
---> PASS PASSWORD
230 Password Ok, User logged in
ftp lcd C:\Users\joe\Documents
Local directory now C:\Users\joe\Documents.
ftp> cd /location/
--->CWD /location/
250 Change directory ok
ftp get "file.xlsx"
---> PORT 192.168.1.121.242.113
500 Port command invalid
RETR file.xlsx
425 Unable to open the data connection
-d
switch toftp
command-line and show us a complete output. – Martin Prikryl