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

.



Relevant Pages

  • Re: Debugging gvim :!cmd with bash
    ... > I've simplified the problem to a trivial script. ... If I invoke it from an xterm command line, ... If that's true for bash, ...
    (comp.unix.shell)
  • Re: Problem Using DoCmd.RunSQL
    ... I had the forms mis-named in the script! ... the form loaded into the control To test that, ... Dim strSql As String ... Below is the command I am using from a button on a form to add a line to ...
    (microsoft.public.access.forms)
  • Re: How to dump content of cmd shell buffer
    ... around with control characters in the ouput. ... But the worst is having to start and stop the script. ... place one finds the command prompt... ... shell buffer' The memory or content of the shell buffer where the ...
    (comp.unix.shell)
  • Re: How to dump content of cmd shell buffer
    ... around with control characters in the ouput. ... But the worst is having to start and stop the script. ... place one finds the command prompt... ... shell buffer' The memory or content of the shell buffer where the ...
    (comp.unix.shell)
  • Re: Perl and IIS - script runs but The page cannot be displayed
    ... >> Working from the command line, you control every aspect of the ... >> concentrate on the script itself. ... > I don't see how one can control every aspect of the environment from ... server too much depends upon how the server and how the server has been ...
    (comp.lang.perl.misc)