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)
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.