cygwin 的期望不适用于网络使用?

发布于 2024-08-21 09:54:34 字数 633 浏览 2 评论 0原文

我需要在 cygwin 上自动执行“net use”命令。

命令是'net use /user:"name" \somewhere'。而'输入'name'的密码连接到'prosseek':'预计会输入密码。

它适用于命令行输入以及在批处理文件中运行时。 当我按如下方式制作预期脚本时,它不起作用。

spawn net use /user:"name" \\prosseek\somewhere
expect "Enter the password for 'name' to connect to 'prosseek':"
send "password\n"
interact

我收到如下错误消息。

spawn net use /user:"name" \prosseek\somewhere
System error 67 has occurred.

找不到网络名称。

发送:无效的生成 ID (4) 执行时 “发送“密码\n”” (文件“conpros”第 9 行)

  • 问:可能出了什么问题?
  • 问:某些 MS 命令(例如“net use”)可以与 cygwin/expect 一起使用吗?

I need to automate the 'net use' command on cygwin.

The command is 'net use /user:"name" \somewhere'. And 'Enter the password for 'name' to connect to 'prosseek':' is expected to enter the password.

It works well with command line input, and when run inside batch file.
It doesn't work when I make a expect script as follows.


spawn net use /user:"name" \\prosseek\somewhere
expect "Enter the password for 'name' to connect to 'prosseek':"
send "password\n"
interact

I get error message as follows.


spawn net use /user:"name" \prosseek\somewhere
System error 67 has occurred.

The network name cannot be found.

send: invalid spawn id (4)
while executing
"send "password\n""
(file "conpros" line 9)

  • Q : What might be wrong?
  • Q : Can some MS command something like 'net use' be working with cygwin/expect?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

肩上的翅膀 2024-08-28 09:54:34

您可能无法将 Cygwin 的 Expect 与非 cygwin 程序一起使用; Cygwin 模拟 posix ptys,而 Windows 程序使用 Windows 自己的终端处理代码,该代码对期望尝试读取和写入的管道一无所知。

你也未能逃脱期望中的反斜杠;请注意,错误消息给出的字符串与您传入的字符串不同。

You probably can't use Cygwin's expect with non-cygwin programs; Cygwin emulates posix ptys, while the Windows programs use Windows' own terminal handling code, which knows nothing about the pipelines that expect is trying to read from and write to.

You've also failed to escape your backslashes in expect; notice that the error message gives a different string from the one you passed in.

念三年u 2024-08-28 09:54:34

这里可能有一些建议:

你能探索到\prosseek\某处吗?如果是这样,我想您可能需要在某个地方转义反斜杠 \\proseek\ 。

网络名称部分还可能表明它无法解析主机名。

Here might be some suggestions:

Can you explore to \prosseek\somewhere? If so I imagine that you may need to escape the backslashes \\proseek\somewhere.

The network name piece might also indicate that it cannot resolve the host name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文