[Kc] scripting for sonet rings

Lokeey lokeey at gmail.com
Thu Nov 16 15:15:13 PST 2006


i've done the expect scripts for less complex stuff...i figured i'd try
doing it with perl this time around since there is much more to it.

On 11/16/06, David Nicol <davidnicol at gmail.com> wrote:
>
> On 11/16/06, Lokeey <lokeey at gmail.com> wrote:
> > Sorry, the NEC is the device...and it's dealing with the ADM's (add drop
> > multiplexer) basically, i just need to log in, and run some rtrv
> commands
> > using the specified CLLI code that is given.
> >
> > its about 900 or so CLLI codes and i'm not 100% sure how to write the
> > script.
>
> okay.  You have a little language, and the responses need to be more
> complex than can be implemented with a tool like GNU expect.
>
> First, you establish to connection, by opening a socket and connecting
> it to your device, then do what you have to to log in.
>
> Oh -- before you even do that, or while your assistant is doing that, draw
> a state diagram of what you want to have happen during the interaction,
> and a list of possible responses and possible commands in each state.
>
> Make a separate package for each state.  the packages can inherit
> from each other if that makes sense, if there are two states that
> are very similar.
>
> In your main program that made the connection and logged in on
> socket S, do something like
>
>      while(defined($response = readresponse(S))){
>                $command = $statefulobject->handle($response);
>                sendcommand(S,$command);
>      };
>
> this approach will work with multiple scripts running simultaneously
> on different sockets each associated with its own stateful object, in
> a select() loop, but that's overengineering for what you're doing i think.
>
> Stateful objects can change their state by transitioning with bless()
>
>   # you can now do $object->T_T_P("reading2") for instance
>   sub TRANSITION_TO_PACKAGE{ bless $_[0], $_[1] };
>



-- 
99 years and counting!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20061116/c40655b0/attachment.html 


More information about the kc mailing list