[rancid] Question about custom command-file and expect

Heasley heas at shrubbery.net
Wed Feb 25 12:52:48 UTC 2015


Am 25.02.2015 um 11:25 schrieb Alan McKinnon <alan.mckinnon at gmail.com>:
> 
> On Wed, 25 Feb 2015 11:41:12 +0100
> Simone Felici <s.felici at mclink.eu> wrote:
> 
>> 
>> Hello,
>> 
>> I would like to connect on a device using rancid and execute some
>> commands *only* in some circumstances. clogin works perfectly to
>> login and using -x to specify a command-list file or -c to execute
>> commands works as well. But what I need is that, based on the
>> response of a command I could execute another command or not.
>> 
>> I.e., after login on a router, executing:
>> 
>> #show ip route <IP_ADDRESS>
>> 
>> IF I obtain:
>> 
>> % Subnet not in table
>> 
>> I need to execute some commands.
>> 
>> If I obtain:
>> Routing entry for <IP_ADDRESS>
>> (...)
>> 
>> THEN I need to do something different.
>> 
>> I've seen there is a [-s script-file] where I could add an expect
>> script. Trying to use it, seems the whole content of clogin is
>> bypassed using the script file. Would be possible to use clogin for
>> login action and then, at the end, use only the script-file to add
>> the rest of the commands with the IF-THEN-ELSE logic?
>> 
>> Thanks for the help!
> 
> I think you are trying to solve a problem that does not exist. Rancid
> won't run a command like this:
> 
> show ip route <IP_ADDRESS>
> 
> Instead, it will show all the routes, grab all of them, sort all of
> them and put the whole lot into cvs. Running specific commands like you
> suggest breaks the rancid model, which is to track everything in a
> repeatable way so that the only differences are configurations.
> 
> I can't think of a circumstance where you would want to do what you
> describe. If that was just an example for illustration, perhaps you
> could describe the real problem?
> 

I think he is using clogin to retrieve data. In that case he could retrieve o/p, disconnect, makes choices and connect again, using -x or -c. Or use -s. Rancid comes with some examples for -s; see the share dir. 

> Alan
> 
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo/rancid-discuss


More information about the Rancid-discuss mailing list