Andrew Falanga wrote:
> Ben C wrote:
>
>>On 2006-03-15, Andrew Falanga <not_real@hp.com> 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?
>
>
> I don't know what exp4 is, nor do I understand what expect_out is.
exp4 is the spawn_id your ssh process "hangs" on
uwe
Received on Sun Apr 30 02:34:17 2006