开发者

cygwin's expect doesn't work with net use?

开发者 https://www.devze.com 2022-12-19 15:22 出处:网络
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 t

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 th开发者_如何学JAVAe 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号