Pergunta

I'm using plink and expect to connect with server from Windows. I've created a text widget .l1 to see what's going on durign connection. Normally when I use this:

catch {exec plink.exe -ssh myserver} res
.l1 insert 1.0 $res

I recieve in a .l1 text widget: "password: " which means that plink works, it is connecting with server and asking me for password.

When I'm using spawn in place of exec:

catch {spawn plink.exe -ssh myserver} res
expect "password: "
.l1 insert 1.0 $res
exp_send "exit"

I recieve some random digits like 1482 or 4584. Why it's not working?

Foi útil?

Solução

Expect remembers what it has seen. I highly recommend reading the "Exploring Expect" book.

Something like this (untested) should help:

spawn plink.exe -ssh myserver
expect "password: "
.l1 insert 1.0 $expect_out(buffer)
exp_send "password\r"
expect "my_shell_prompt$ "
.l1 insert end $expect_out(buffer)
... etc
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top