Page 1 of 1

Error uploading a file from a .bat

Posted: 2021-02-22 18:38
by diaverso
Hi I created a .bat file to upload a file directly to a server.

This is the code that I have:

Code: Select all

    @echo off
    echo user usuario> ftpcmd.dat
    echo pass>> ftpcmd.dat
    echo lcd H:\>> ftpcmd.dat
    echo put *.rar>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat IP
    del ftpcmd.dat
It connects to the server perfectly.
Then it says that the connection is being made to upload the file and stays in that step.

"In the ftp of the server put this information:
230 Logged on
PORT 83,54,203,226,196,4
200 Port command successful
STOR diaverso-20210221133120.rar
150 Opening data channel for file upload to server of "/diaverso-20210221133120.rar"
425 Can't open data connection for transfer of "/diaverso-20210221133120.rar"
421 Connection timed out."

With the filezilla client program I can upload the files without any problem.
I attach a video to see the steps.
https://www.youtube.com/watch?v=xPDlI01aQ0Q


I do not understand why the connection is closed ...

Re: Error uploading a file from a .bat

Posted: 2021-02-22 23:38
by boco
Because the sh*tty commandline FTP client from Windows that's often used in batch files does not support the firewall-friendly Passive mode that was introduced decades ago. If you are behind a router, it is completely useless, as it cannot be further configured.

Search the web for "lftp windows" to get an actually decent command line client.