Uwe Klein wrote:
> 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.
Ok, what gives? I put the interact command at the end (in place of the
expect .*). Everything works now AND I don't have to interact with the
script, which is kind of weird since I would have expected otherwise
using the interact command.
So, simply put, why does interact fix the problem?
--
---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.
Received on Sun Apr 30 02:34:21 2006