Can't upload a file to FTP with WScript.Shell / cmd [duplicate]

自作多情 提交于 2019-12-08 10:56:09

问题


I've created simple HTA-page

<input type="button" value="Run" onclick="run();">
<script>
function run() {
 var shell = new ActiveXObject('WScript.Shell');
 shell.run('cmd /c ftp -i -s:D:\ftp.bat',0,true);
}
</script>

And on my disk D created ftp.bat

open mydomain.com
username
password
cd /public_html
mput D:\filetobeuploaded.txt
quit

But when I run script on the HTA-page, file is not being uploaded to FTP.

If I run my BAT-file via cmd.exe, I succesfully connect to my FTP, but after mput command I get

500 I won't open a connection to 111.111.111.111 <only to 222.222.222.222>

425 No data connection

where 222.222.222.222 is my IP

As I can understand there are two separate problems:

1. I can't connect with FTP if I use

shell.run('cmd /c ftp -i -s:D:\ftp.bat',0,true);

2. I can't upload a file to FTP (no data connection)

来源:https://stackoverflow.com/questions/49865865/cant-upload-a-file-to-ftp-with-wscript-shell-cmd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!