in reply to Re: Broken Net::Telnet::Netscreen module?
in thread Broken Net::Telnet::Netscreen module?

I tried reverting the module with the same results, so it appears the problem is in the script.

Here's the debug output:

unset address Untrust AutoGenRule_1.1.1.1 at C:/Perl/lib/Net/Telnet.pm + line 535 Net::Telnet::error('Net::Telnet::Netscreen=GLOB(0x34787ec)', 'unset ad +dress Untrust AutoGenRule_1.1.1.1\x{a}') called at C:/Perl/site/lib/N +et/Telnet/Netscreen.pm line 150 Net::Telnet::Netscreen::unsetValue('Net::Telnet::Netscreen=GLOB(0x3478 +7ec)', 'address', 'Untrust AutoGenRule_1.1.1.1') called at Rules.pl l +ine 112 main::unset_config() called at Rules.pl line 56 Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info.

I'm not entirely sure how to interpret this. Any thoughts?

Replies are listed 'Best First'.
Re^3: Broken Net::Telnet::Netscreen module?
by jethro (Monsignor) on Aug 13, 2008 at 19:16 UTC

    This means the error function gets called in your method unsetValue. Since the parameters are definitely not empty the call is probably because of this line

    if ($result =~ /\w+/) { return $self->error($result); }

    this line should be on line 150 of your changed Netscreen.pm. I don't know what is in $result, but normally you should get some error message while running the script and that return value is probably what the telnet session answered when the unset command was issued to the netscreen machine. Noticing (and reporting) that error message would have made things much easier

    If you don't see this error message, you might put something like  print STDERR "<<$result>>\n"; between line 149 and 150 into Netscreen.pm.

    The probable cause of that error is that the unset command on the netscreen machine doesn't need/want/allow a parameter $value, because you are UNSETTING and not setting a value. So you might try the following line in your unsetValue method

    my @results=$self->cmd("unset ".$setting);

      The $value in unsetValue is ok. The command sent to the firewall will end up being <unset object name> or something like "unset address Autogen_x".

      The regex used to check for the error is a little flawed though, it should be looking for "^-". I updated the methods with this, but the script still exits after the first command. The module does report errors correctly now though.

      I've tried die, eval, and even clucking exit, at tye's suggestion. The script just exits silently.

      Updated methods for Net::Telnet::Netscreen:

        Too bad, I thought I had the right idea

        You are not very clear about whether you get error messages or not. If you get any, please post them. Otherwise you could repeat the trace and show that output if it changed.

        I don't remember the regex syntax $result=\/^-/. Shouldn't the \ be ~ ?

        UPDATE: Also you might use Data::Dumper to print out everything in @result, just to be sure what you get back