Hello, I recently configured up Perl on Cygwin for my XP machine. I wrote a script using Net::Appliance::Session to log into Cisco switches and give me a count of how many disabled ports there are. Everything works fine, but I noticed that my SSH processes are not closing. For example, If I run the script against 6 switches, I have 6 SSH processes still open. Has anyone else ever seen this. And do you possibly know what I could do to try and fix it? Thanks. P.S. Here's the script code:
#!/usr/bin/perl use Net::Appliance::Session; $switch_file = "/etc/scripts/switches.txt"; $user = "xxxxx"; $pass = "xxxxx"; $out_file = ">> /etc/scripts/portcount.txt"; if (-e "/etc/scripts/portcount.txt") { system("rm -f /etc/scripts/portcount.txt"); } open(OUT, $out_file); foreach $store_number (@ARGV) { chomp($store_number); open(STSWITCH, $switch_file); foreach $switch (<STSWITCH>) { chomp($switch); next if $switch =~ /^#/; next if $switch !~ /\.st${store_number}\.meijer\.com/; $s = Net::Appliance::Session->new( Host => $switch, Transport => 'SSH'); $s->do_privileged_mode(0); eval { $s->connect( Name => $user, Password => $pass, SHKC => 0); $count = 0; @output = $s->cmd("show ip int brie"); $s->close(1); foreach $line (@output) { next if $line !~ /FastEthernet/; next if $line !~ /administratively down/; $count++; } $total += $count; #print $switch ." unused ports: ". $count ."\n"; }; if ($@) { print "Error while accessing the device: $switch\n"; print "The error was: $@\n\n"; } } print OUT "Total for store #". $store_number .": ". $total ."\n"; $total = 0; close(STSWITCH); } close(OUT);

In reply to Net::Appliance::Session - using SSH will keep process open by scottdware

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.