[j-nsp] JUNOS Perl API version?

Bjørn Mork bjorn at mork.no
Mon Jul 28 04:22:04 EDT 2008


Richard A Steenbergen <ras at e-gerbil.net> writes:
> On Sat, Jul 05, 2008 at 09:51:35AM -0700, Shane Ronan wrote:
>> For us uninitiated, what is contained in this API?
>
> At this point there is no real reason to keep running junoscript, it has 
> been replaced by the standardized multi-vendor version called netconf.
>
> http://www.juniper.net/support/xml/netconf/index.html
>
> I personally wish they wouldn't roll a new version with every junos 
> release, since the perl API rarely changes, and then when it does you have 
> no idea that an important change has occured. 

Or that a less important change still may screw up existing
installations.  Like a semi-recent change to JUNOS::Access::telnet,
which is shared between all versions and overwritten by default on every
install.  It has the ugliest bit of buggy perl code I've ever seen:

    my $script = "use Expect; " .
        "my \$exp = Expect->spawn(\"telnet\"); " .
        "if (\$exp->expect($timeout_value, '-re', \"telnet\")) { " .
        "  print \$exp \"unset autologin\\r\" ;" .
        "  if (\$exp->expect($timeout_value, '-re', \"telnet\")) { " .
        "    print \$exp \"open $self->{hostname}\\r\" ;" .
        "    if (\$exp->expect($timeout_value, '-re', \"[lL]ogin:\")) { " .
        "      print \$exp \"$self->{login}\\r\" ;" .
        "      if (\$exp->expect($timeout_value, '-re', \"[pP]assword:\")) { " .
        "        print \$exp \"$self->{password}\\r\" ;" .
        "        \$exp->interact();" .
        "      }" .
        "    }" .
        "  }" .
        "}";
    my $command = "perl -e '" . $script . "'";


This will of course break for a number of reasons.  I won't even try to
list them all.


Bjørn


More information about the juniper-nsp mailing list