【发布时间】:2014-12-21 15:30:09
【问题描述】:
我需要使用ssh 和expect 远程运行批处理脚本并将结果复制到文本文件中。我该怎么做?
这行得通:
$ ssh -t username@dshost 'D:\scripts\a.bat' >file.txt
但这不是:
#! /usr/bin/expect --
spawn ssh -t username@shost 'D:\\scripts\\a.bat' >file.txt
expect "*assword:*" { send "pwd\r" }
expect "yes/no" send "yes\r"
exit
我收到以下错误。
The filename, directory name, or volume label syntax is incorrect.
【问题讨论】:
-
你试过
/d:/scripts/a.bat吗? -
这不是回答你的问题,而是把
exit改成expect eof -
两个命令中的文件夹名称不同。它找不到脚本s。
-
那是一个错字。我已经编辑了问题中的代码。将退出更改为期望 eof - 仍然不起作用
标签: shell batch-file ssh expect