Hello monks!

I have written a perl script that queries information about the machines listed in our load balancer (Netscaler which runs a BSD based OS).

I am using Net::SSH::Perl to query the load balancer. I notice that the script can ssh into the load balancer, and the print statements work, but the commands to the load balancer such as:
$ssh->cmd("show lb vserver $lbvserver");

do not execute.

What am I missing in order to get the commands to the load balancer to execute?

Here's the code:

#!/usr/bin/perl # use strict; use warnings; # # use Net::SSH::Perl; my $user="bluethundr"; my $pass="secret"; my $dir="$ENV{HOME}/data"; open LBVSERVERS, '<', "$dir/lb-vserver" or die "Couldn't open file: $! +"; open CSVSERVERS, '<', "$dir/cs-vserver" or die "Couldn't open file: $! +"; my $ssh = Net::SSH::Perl->new("10.50.0.1"); $ssh->login("$user", "$pass"); print "\n\n\n\n\n**********LB VSERVERS**********\n\n\n\n\n"; while (my $line = <CSVSERVERS>) { chomp $line; my ($number, $lbvserver) = split(/\s+/, $line); print "show lb vserver $lbvserver\n"; $ssh->cmd("show lb vserver $lbvserver"); print "Ready for next lb vserver? (y/n): "; chomp(my $ans = <STDIN>); if ($ans=~/y|Y/) { next; } else { last; } } print "\n\n\n\n\n**********CS VSERVERS**********\n\n\n\n\n"; while (my $line = <LBVSERVERS>) { chomp $line; my ($number, $csvserver) = split(/\s+/, $line); print "show lb vserver $csvserver\n"; $ssh->cmd("show lb vserver $csvserver"); print "Ready for next lb vserver? (y/n): "; chomp(my $ans = <STDIN>); if ($ans=~/y|Y/) { next; } else { last; } } print "\n\n\nEnd of line.\n\n\n"; close LBVSERVERS; close CSVSERVERS;


Thanks monks!

In reply to Net::SSH::Perl doesn't execute commands by bluethundr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.