Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My FTP batch script is stuck on "200 PORT command successful" and doesn't upload the files to server

I've tried everything I found in Google results about

200 PORT command successful

but nothing has helped.

Can anyone assist to solve this issue please?

The code of "runScript.bat:

ftp -s:"C:\automation\fileup.bat" myserver.com

The code of "fileup.bat:

username
password
ascii
cd "/public_html/reports/"
lcd "C:\automation\tests\HtmlReporter"
prompt
mput *
disconnect
close
bye

The console log:

C:\automation>ftp -s:"C:\automation\fileup.bat" myserver.com
Connected to myserver.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 7 of 500 allowed.
220-Local time is now 04:40. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
User (server26.000webhost.com:(none)):
331 User username OK. Password required

230-OK. Current restricted directory is /
230-449 files used (4%) - authorized: 10000 files
230 16742 Kbytes used (1%) - authorized: 1536000 Kb
ftp> ascii
200 TYPE is now ASCII
ftp> cd "/public_html/reports/"
250 OK. Current directory is /public_html/reports
ftp> lcd "C:\automation\tests\HtmlReporter"
Local directory now C:\automation\tests\HtmlReporter.
ftp> prompt
Interactive mode Off .
ftp> mput *
200 PORT command successful
like image 398
Idan E Avatar asked Jun 02 '15 08:06

Idan E


1 Answers

This looks like a typical problem with the FTP active mode. The server cannot connect back to your machine to establish a data transfer connection.

That typically happens as nowadays most client machines are behind a firewall or NAT or both, what prevents the FTP active mode from working. To make the active mode working you need to open your firewall (not recommended) and/or configure NAT routing rules.

See my article on FTP modes and configuring network for the active mode.


Or you use the passive FTP mode. The Windows ftp.exe client does not support the passive mode though, what makes it pretty useless nowadays.

So you need to use another command-line FTP client. A majority of FTP clients do support the passive mode.

For example with WinSCP your runScript.bat would be like:

winscp.com /command ^
    "open ftp://username:[email protected]/" ^
    "cd /public_html/reports/" ^
    "lcd C:\automation\tests\HtmlReporter" ^
    "put *" ^
    "exit"

Note that WinSCP defaults to the passive mode.

For details see WinSCP guides for:

  • Automating file transfers to FTP server
  • Converting Windows FTP script to WinSCP script

(I'm the author of WinSCP)

like image 192
Martin Prikryl Avatar answered Sep 30 '22 14:09

Martin Prikryl