Re: [Expect] Need to have explanations for the use of the expect command
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: [Expect] Need to have explanations for the use of the expect command

From: Uwe Klein <uwe_klein_habertwedt@t-online.de>
Date: Wed Mar 15 2006 - 18:28:56 CET

Andrew Falanga wrote:
> Hello,
>
> Back to an issue I'd asked for help on some months ago and I'm just now
> getting back around to it. I went and read through my original post and
> the answers to that post, tried some the suggestions and some new things
> and I'm still at the same place. It's not working and I don't know why.
>
> 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" }
> }
>
>
> Actually, that's not just basically the script, it is the script. As
> far as I can tell, this isn't working. The script does spawn the ssh
> process, but when the prompt comes for root's password, it just sits
> there for 5 or 10 seconds and then, apparently, times out.
>
does the sshd on your $host really request the password with

        "password" ??

usually its "Password: "

do some experimenting:

expect \
           password { puts "password!!"
         } Password { puts "Password!!"
         } timeout { expect -re .* ; puts TIMEOUT:seen:\"$expect_out(buffer)\"
   }

use "timeout" to display what has been received upto now!

take care to [expect] the last chars sent by the app!
otherwise you might send something back before your app is ready.
using delays tends to break easily. sleeping for seconds takes ages..

uwe
Received on Sun Apr 30 02:34:02 2006