Question

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?
Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top