web-dev-qa-db-ja.com

FTPバッチスクリプトが「200PORTコマンド成功」でスタックし、ファイルをサーバーにアップロードしません

私はGoogleの結果で見つけたすべてを試しました

200PORTコマンドが成功しました

しかし、何も助けにはなりませんでした。

誰かがこの問題を解決するのを手伝ってくれる?

"runScript.bat:のコード

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

"fileup.bat:のコード

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

コンソールログ:

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

WinSCPに関するエラー(Martinの場合) ":

C:\Users\idan>cd c:\automation\

c:\automation>runFTP.bat

c:\automation>winscp.com /command     "open ftp://user:[email protected]/"     "cd /public_html/reports/"     "lcd C:\automation\tests\HtmlRepo
rter"     "put *"     "exit"
'winscp.com' is not recognized as an internal or external command,
operable program or batch file.

c:\automation>
8
Idan E

これは、FTPアクティブモードの一般的な問題のように見えます。サーバーがマシンに接続してデータ転送接続を確立することはできません。

これは通常、ほとんどのクライアントマシンがファイアウォールの背後にあるか、NAT、またはその両方であるため、FTPアクティブモードが機能しないためです。アクティブモードを機能させるには、ファイアウォールを開く必要があります(推奨されません)。 )および/またはNATルーティングルールを構成します。

FTPモードとアクティブモード用のネットワークの構成 に関する私の記事を参照してください。


または、パッシブFTPモードを使用します。窓 ftp.exeクライアントはパッシブモードをサポートしていませんが、最近ではかなり役に立たなくなっています。

したがって、別のコマンドラインFTPクライアントを使用する必要があります。 FTPクライアントの大部分はパッシブモードをサポートしています。

たとえば、 WinSCP your runScript.batは次のようになります:

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

WinSCPのデフォルトはパッシブモードです。

詳細については、以下のWinSCPガイドを参照してください。

(私はWinSCPの作者です)

13
Martin Prikryl

まったく同じ問題(「200 PORTコマンドが成功しました」が画面に表示され続ける)があり、解決することができました。

まず第一に、Windowsftp.exeはパッシブモードをサポートしていないという投稿がインターネット上にたくさんあります。本当じゃない:

ftp> quote pasv

227パッシブモードに入る

私の場合、実際のIPを備えたWindows 2012R2サーバーがありました。パッシブモードに切り替えても問題は解決しませんでしたが、「200PORTコマンドが成功しました」でスタックしました。同時に、WinSCPは正常に機能しました。解決策は、FTPサーバーからローカルのftp.exeへの外部接続を許可する受信ファイアウォールルールを作成することでした。

1
Sergei Tche