creating variables on the fly
Posted by soop (soop), 19 March 2008I can't find anything unique enough to specify as an end of file for a running config, and the promts for the routers I'm using are all different. What I'd like to do is grab the hostname from the running config with
"show run | i hostname" (which actually gives 2 matches) and then specify what follows hostname as $prompt.
Is this possible? What is the comand for this?
Posted by admin (Graham Ellis), 20 March 2008If you have your hostname in a variable called hostname you can use that as a part of our expect string:
expect "$hostname $prompt" ...
Posted by soop (soop), 26 March 2008I know that, but I want to define what $hostname is automatically based on what expect outputs
Posted by admin (Graham Ellis), 26 March 2008Yes ... you expect a line that contains the hostname, use a regular expression to extract it from expect_out(string) then expect in the way I described.
Other Forum Posts
Follow us on ...
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho