首页 > 解决方案 > 具有从 cmd 调用的输入重定向的批处理脚本自动添加数字参数

问题描述

我有一个名为 runcmd.bat 的 cmd 批处理脚本,如下所示

plink.exe -ssh 1.11.1.1 -l kaka -pw babay < commands.txt >output.txt

从 CMD 调用此批处理脚本时,会生成以下错误:

 C:\Users\ASAD\Desktop\PuTTY>runCmd.bat

C:\Users\ASAD\Desktop\PuTTY>c:

C:\Users\ASAD\Desktop\PuTTY>cd \

C:\>cd "Users\ASAD\Desktop\PuTTY"

C:\Users\ASAD\Desktop\PuTTY>plink.exe -ssh 1.11.1.1 -l kaka -pw babay  0<commands.txt 1>>output.txt
The system cannot find the file specified.

C:\Users\ASAD\Desktop\PuTTY>
The system cannot find the file specified.

如果您可以看到,它会在 < 和 > 输入和输出重定向运算符之前自动添加 0 和 1。

我正在使用 Windows 8.1 x64。我也在 windows 2012 R2 Server 中尝试过同样的方法,但最终都显示相同。

我希望脚本在输入和输出重定向器之前执行而不添加任何数字。

标签: batch-filecmd

解决方案


推荐阅读