cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Automating telnet sessions with libcurl

From: <man_at_tfhs.net>
Date: Tue, 20 Dec 2005 18:48:38 -0000

On Tue, Dec 20, 2005, Adam M <curl_at_irotas.net> said:

> On Tue, 20 Dec 2005 17:45:19 -0000, man_at_tfhs.net said:
>> dont re-invent the wheel. see if existing tools will work.
>>
>> http://www.kiwisyslog.com/cattools2.htm
>>
>> http://www.experts-exchange.com/Hardware/Routers/Q_21108412.html
>>
>> i am a perl hacker, so i use the Net::Telnet::Cisco way myself...
>
> Hi Allan,
>
> I should be more clear about my constraints here.
>
> First of all, the automation needs to be done from within a C/C++
> application running on Linux. For this particular case, the
> responsiveness (i.e., latency of rule interpretation and insertion) is
> extremely sensitive, and must be "as fast as possible".

hmm, automatic IDS ACL creation? just let me get my hands on your upstream
router, so i can close every port on your box with a few spoofed packets
:)

> My initial approach was to call a C-Kermit script from within the C/C++
> application, but the additional overhead of logging in (i.e.,
> authenticating) every time has become too expensive.

sure. especially with the enable passwd on top of initial login.

> As the automation needs to be done from Linux, CatTools is not an
> option. And unless there's some clever way of staying logged in even
> while using external Perl/Kermit scripts, it seems that the C/C++
> application needs to log into the switch on startup and log out on exit.

if you dont kill the external script, it wont disconnect, iirc. so you
would need to open the perl prog, and send it 'commands' you would like it
to run. you will need to do some select() magic on both ends if you are
going to have perl prog return status after each command without blocking.
then you can have a pool of external children, one per device, in case you
want to talk to multiple at once.

> I've also been reading a bit on the C bindings for EXPECT, which may in
> fact be the way to go. I had originally leaned towards libcurl because
> the learning curve seemed to be easier than EXPECT, but perhaps it just
> doesn't do what I need.
>

i have never used libcurl telnet, but expect is not too bad for scripting.
i have not used it's C bindings. good luck.

allan

-- 
m. allan noah
IT Director, TfHS.net
ph# (804) 355-5489
tf# (866) 724-9722
fx# (804) 355-0477
Received on 2005-12-20