Re: Using expect with telnet menu



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
.



Relevant Pages

  • Re: help on xml
    ... the only reason that i wanted to send xml file. ... Your host doesn't allow you to use require_once? ... options for well structured code are very limited. ... and your host doesn't have a certain PEAR ...
    (comp.lang.php)
  • Re: Pear install on shared server problem
    ... and I followed all the instructions in the Pear Manual for setting up a local copy on a shared host. ... Everything seems to have gone fine, the directory structure is set up in my home directory in a folder called pear, and when i run config-show everything points to this directory. ... is a spam trap. ...
    (comp.lang.php)
  • Pear install on shared server problem
    ... I am trying to set up a local verion of Pear in my shared account, ... which my host said I can do. ... Fatal error: main: Failed opening required 'DB.php' ...
    (comp.lang.php)
  • Re: Using expect with telnet menu
    ... to log into host pear.domain.com, ... pear may become option 4 or 2. ... Got the prompt without finding a pear" ... Glenn Jackman ...
    (comp.lang.tcl)
  • Re: Consolidating - adacrypt
    ... Ramsi to incorporate it. ... She may narrow once, prompt briefly, then ... explain v the host despite the commission. ...
    (sci.crypt)