using expect to log into devices


:: 'close $spawn_id' is wrong, so maybe that's it?

:: man expect
:: close [-slave] [-onexec 0|1] [-i spawn_id]
:: closes the connection to the current process.
:: ... The -i
:: flag declares the
:: process to close corresponding to the named
:: spawn_id.
   <.. snip ..>

* (Scott Weeks) [Sat 21 Jul 2018, 22:38 CEST]:

I had already done this in PERL, but, even though we have PERL, we are not allowed to download modules here. So, I'm redoing it in Expect. I thought someone would say a "oh just <blah, blah> and you're done" type of response.

Well, what you're doing right here is reimplementing rancid. Which is wholly unnecessary because we already have rancid, and a more modern alternative named oxidized. And you've gotten that response already.

Fine as a personal exercise, of course. The inability to download modules seems sadistic to me, though.

  -- Niels.

And given the adage "Never create a rule you can't enforce", I
wonder how they enforce it - have to be pretty hardcore to make
sure that stuff doesn't get imported via USB or tethering off a
cellphone. (Or more correctly, I know how they do those sort of
things if you're a spook agency or doing classified research - how
do you make it palatable to employees in corporate sites?)

Have you looked into utilizing Ansible?

Yes, we use Ansible heavily on production services.

But Ansible doesn't *stop* somebody from downloading modules, especially
if it's a laptop used for diagnosis/testing.