Re: Using expect with telnet menu
- From: dgl <davelemmon@xxxxxxxxxxx>
- Date: Tue, 30 Oct 2007 10:08:11 -0700
On Oct 29, 8:24 pm, Glenn Jackman <gle...@xxxxxx> wrote:
At 2007-10-29 07:59PM, "dgl" wrote:
I am trying to write a script to telnet from a power broker jumpbox to
a host. The hosts are listed in a numbered menu that changes
periodically. The list below is similar to my actual list. If i want
to log into host pear.domain.com, I would select "3". If the list is
modified, pear may become option 4 or 2. How can I have expect match
pear.domain.com and return it's current menu option?
==============================================================================
Power Broker Access
==============================================================================
1 apple.domain.com 3 pear.domain.com 5
cherry.domain.com
2 orange.domain.com 4 banana.domain.com 6 lime.domain.com
==============================================================================
Please choose a system:
Untested:
expect {
-re {(\d+)\s+pear\M} {
set pear_num $expect_out(1,string)
exp_continue
}
-re {Please choose a system:}
}
if { ! [info exists pear_num]} {
error "No fruit for you! Got the prompt without finding a pear"
}
exp_send -- "$pear_num\r"
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
awesome, i will try this. my crude solution was:
expect {
"1 pear" {send "1\r"}
"2 pear" {send "2\r"}
"3 pear" {send "3\r"}
"4 pear" {send "4\r"}
"5 pear" {send "5\r"}
}
it worked but is inefficient. I will post the results.
.
- References:
- Using expect with telnet menu
- From: dgl
- Re: Using expect with telnet menu
- From: Glenn Jackman
- Using expect with telnet menu
- Prev by Date: Re: Standard DBI Proposal
- Next by Date: Expect spawns on 64-bit Windows
- Previous by thread: Re: Using expect with telnet menu
- Next by thread: Re: (WWW.CNCIRCLE.COM)cheap wholesale hoodies, jeans, discount. wholesale nike shoes, adidas,puma, lacoste,parada.lv.gucci oulet store
- Index(es):
Relevant Pages
|