Re: How to spawn a session in new window using expect?



On Oct 24, 12:45 pm, h...@xxxxxxxxx (Hugo Villeneuve) wrote:
chets <cheta...@xxxxxxxxx> wrote:
Hi,

i want to ssh a new session in GUI window.

for that we can use xterm here.

eg: xterm -e ssh root@hostname
will open new window asking for password.

now i got stucked b/w xterm & expect

when i click button im getting a new window asking for password, but i
want to proceed without manually entering password.
i.e. i'll provide password using expect in script but this is not
working:

log_user 0
set timeout 3
set id [exec xterm -e ssh $host]
expect -i $id -re "Password: "
exp_send -i $id "abcd123\r"
interact

on executing this a new window will open,but it hungs asking for
password
i don't know is e xpect is not working or exp_send is not sending
password

xterm open its own pseudo-terminal for the -e command (or shell) to run
into.

It's unrelated to pseudo-terminal expect setup for sub-programs use
(because it's their stdin/stdout/stderr).

Thus expect as no control and no idea about what's happening inside the
xterm.

You could run another expect script for the -e command.

Or ask xterm to re-use expect's pseudo-terminal (-S switch) and have
expect control everything you'll see inside the xterm. I remember this
is documented in my Expect book but it's at work :( and I'm rusty on my
expect and tcl skills.

Although, in your situation, I would probably just set up ssh keys
without password rather than hard-coding a remote password into a
script.

That's if running ssh-agent/ssh-add over my entire X session wasn't
pratical.

Good luck with your project.

I was gonna say this isn't a expect group but there isn't seem to be
one. Although "comp.lang.tcl" might come close.

Hay Thanks alot for the response, will try with ur suggestions hope i
will succeed...

.