Wscript.shell.run和Wscript.shell.exec不显示相同的输出
Wscript.shell.run and Wscript.shell.exec do not display the same outputs
我在Javascript中使用ActiveXObject。
var shell = new ActiveXObject("WScript.Shell");
exec = shell.exec('cmd /c ftp -i -A -s:file.ftp host);
var output = exec.StdOut.ReadAll();
我得到预期的错误"无法创建文件",因为该文件已存在于服务器上。这里一切都很好。但是输出不会显示ftp的错误代码,而Run方法会显示(553无法创建文件)。
我不使用Run方法,因为唯一可能的输出是将输出重定向到客户端机器上的文件中。
相信我,我读了很多网站(包括Windows官方对Run、Exec的描述)
如何使用WScript.Shell.Exec命令获取ftp命令的错误代码?
更多信息:
exec.StdOut.ReadAll()输出->
"bin
cd my_dir/
mput file_path file_path
Could not create file.
Could not create file.
quit"
WScript.shell.run->的输出文件
ftp> bin
200 Switching to Binary mode.
ftp> cd my_dir/
250 Directory successfully changed.
ftp> mput file_path file_path
200 PORT command successful. Consider using PASV.
553 Could not create file.
200 PORT command successful. Consider using PASV.
553 Could not create file.
ftp> quit
221 Goodbye.
好的,我在一篇8年前的帖子中找到了解决方案。(http://computer-programming-forum.com/61-wsh/813f07658378176c.htm)
为了使用Exec方法从ftp命令中获得完整的输出,必须在ftp命令中添加-v选项。工作起来很有魅力。
var shell = new ActiveXObject("WScript.Shell");
exec = shell.exec(cmd /c ftp -i -v -A -s:file.ftp host);
var output = exec.StdOut.ReadAll();
相关文章:
- Django可以'不能在设置中导入ckeditor,但可以在shell中导入
- 如何在 JavaScript 中运行 shell 命令
- 将标志从Node/Express应用程序Python shell传递到Python脚本
- 从shell脚本中杀死Node.js程序
- Shell样式的函数调用
- 从shell脚本向js脚本传递变量
- 在SAPUI5项目中使用sap.ui.ux3.Shell时,无法在iphone上滚动
- 更新int数组会在Mongo-shell中转换为双数组
- 代码在shell中运行,但提供'可以't查找变量'从文件运行时出错
- Durandal viewChanged event in shell.js
- 在 Javascript 中运行命令 Wscript.shell ActiveX
- Javascript Wscript.Shell命令无法通过单击浏览器中的按钮来工作
- Wscript.shell.run和Wscript.shell.exec不显示相同的输出
- 使用WScript.shell编写文件
- WScript.Shell CurrentDirectory返回调用应用程序的位置,而不是当前位置
- ActiveXObject(“WScript.Shell");在Firefox中未定义
- wscript.Shell在javascript中工作,而不是vbscript
- 如何使用WScript.Shell打开pdf
- 使用WScript.shell activeX执行命令行
- 使用WScript.shell activeX在javascript中执行命令行