Re: [Expect] Need to have explanations for the use of the expect command
- From: Uwe Klein <uwe_klein_habertwedt@xxxxxxxxxxx>
- Date: Wed, 15 Mar 2006 20:22:23 +0100
Andrew Falanga wrote:
Ben C wrote:--------------------------^^^
On 2006-03-15, Andrew Falanga <not_real@xxxxxx> wrote:
Hello,
...
The script is, basically,
#! /usr/bin/expect
set host [lindex $argv 0]
spawn ssh root@$host "cd logs; ls"
expect {
-re password { sleep 1; exp_send "password\r" }
}
Most hosts I've logged into put the "password" line with a capital P.
password doesn't match Password.
Tip: expect -d is very useful for seeing why this kind of thing doesn't
work.
Otherwise I think the script is OK.
Ok, I'm going to paste in the result of using the -d option:
expect version 5.40.0
argv[0] = /usr/bin/expect argv[1] = -d argv[2] = ./exp.expect argv[3]
= remtest1
set argc 1
set argv0 "./exp.expect"
set argv "remtest1"
executing commands from command file ./exp.expect
spawn ssh root@remtest1 cd logs; ls
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {24283}
expect: does "" (spawn_id exp4) match regular expression "password"? no
root@remtest1's password:
change your expect term to include the ":" and the trailing " " (if existant)
expect: does "root@remtest1's password: " (spawn_id exp4) match regular
expression "password"? yes
expect: set expect_out(0,string) "password"
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "root@remtest1's password"
send: sending "utah1\r" to { exp4 }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this the last line you get right?
if you put an [ expect -re .*] at the end
you will see the trace of succesful login ( or not)
if you put an [interact] at this point in your script
you will be able to interact with your test setup.
what is your next step to accomplish now?
exp4 is the spawn_id your ssh process "hangs" on
I don't know what exp4 is, nor do I understand what expect_out is.
uwe
.
- Follow-Ups:
- Re: [Expect] Need to have explanations for the use of the expectcommand
- From: Andrew Falanga
- Re: [Expect] Need to have explanations for the use of the expectcommand
- From: Andrew Falanga
- Re: [Expect] Need to have explanations for the use of the expectcommand
- References:
- [Expect] Need to have explanations for the use of the expect command
- From: Andrew Falanga
- Re: [Expect] Need to have explanations for the use of the expect command
- From: Ben C
- Re: [Expect] Need to have explanations for the use of the expect command
- From: Andrew Falanga
- [Expect] Need to have explanations for the use of the expect command
- Prev by Date: Re: How to exit from currently running Tcl command in C++
- Next by Date: Re: Is garbage collection here yet?
- Previous by thread: Re: [Expect] Need to have explanations for the use of the expect command
- Next by thread: Re: [Expect] Need to have explanations for the use of the expectcommand
- Index(es):
Relevant Pages
|