PSEXEC 输入重定向
我正在使用 Psexec 运行远程批处理文件。我将输入传递给 psexec 并将其重定向到远程批处理文件,该文件寻求文件名作为其输入。然而,在重定向时,文件名变成垃圾,如@##&#*,这意味着实际的文件名不会传递到用户提供的批处理文件。谁能告诉这可能是什么原因。
pause
cd c:
set /P INPUT=Type input: %=%
echo Your input was: %INPUT%
copy %INPUT% \\remotemachineip\C$ && c:\psexec \\machineip cmd /k "c:\batchfile.bat arg1 < %INPUT% & del %INPUT%" -e -c -f -i
pause
I am using Psexec to run a remote batch file. I pass input to psexec and redirect it to the remote batch file which seeks a filename as its input. However while redirecting, the file name becomes a garbage as @##* which means actual file name is not passed to batch file which the user gives. can anyone tell what might be the reason for this.
pause
cd c:
set /P INPUT=Type input: %=%
echo Your input was: %INPUT%
copy %INPUT% \\remotemachineip\C$ && c:\psexec \\machineip cmd /k "c:\batchfile.bat arg1 < %INPUT% & del %INPUT%" -e -c -f -i
pause
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
远程批处理文件,从本地计算机上的上述批处理文件命令中寻求输入。所以%1(下面的命令)会被用户输入的%INPUT%(上面代码内容中cmd.exe中的第二个参数)替换,并执行sqlcmd命令。因此,用户在上面的批处理文件中传递的输入将成功重定向到下面的批处理文件(内容),并且其中的命令(下面的sqlcmd)将成功执行。
例如,如果我将 %INPUT% 指定为 c:\inputfile.xls ,它将被重定向到 SQLCMD 命令而不是 %1,因此它将执行为--
the remote batch file which seeks input from the above batch file commands on the local machine. so %1(below command) is replaced by the %INPUT%(the second argument in the cmd.exe in the above code content) which the user enters and the sqlcmd command will be executed. so the input which the user passes in the above batch file will be successfully redirected to the below batch file(content) and the command(sqlcmd below) in it will be successfully executed.
for e.g if I give %INPUT% as c:\inputfile.xls it will be redirected to SQLCMD command in place of %1, so it executes it as--