Hi Neil, Thanks for the response. I have modified the code accordingly. Still I am getting error. I am very new to perl This is the error ********* ERROR: Could not create socket: Invalid argument Use of uninitialized value $servername in printf at ./new.pl line 42. Use of uninitialized value $portnumber in printf at ./new.pl line 42. **************

#!/usr/bin/perl -w use Data::Dumper; use Expect; use strict; use IO::Socket; use warnings; my $exp = new Expect; $exp->log_file("SSHLOGFILE.txt"); $exp->log_stdout(0); my $user = '*****'; my $pw = '**********'; if( ! defined $ARGV[0] ) { print "Usage: new.pl source destination\n"; exit; } my $file1 = $ARGV[0] or die "Need to get CSV file on the command line\ +n"; my $file2 = $ARGV[1] or die "Need to get CSV file on the command line\ +n"; open my $info, $file1 or die "Could not open $file1: $!"; while( my $line = <$info>) { print $line; open( my $ssh_fh, "|-", 'ssh xxxxx@yyyy ps aux |' ) or die " Could not ssh [$!]\n"; open( my $data_fh, ">", $file2 ) or die "Could not open [$file2] [$!]"; for (my $nice = <$data_fh>) { chomp ($nice); my ($servername, $portnumber) = split (',', $nice); print "$servername \n"; print "$portnumber \n"; while ($ssh_fh) { printf "%s %s\n", $servername, $portnumber; my $sock = new IO::Socket::INET (PeerAddr => $ +servername,PeerPort => $portnumber,Proto => 'tcp'); print "ERROR: Could not create socket: $!\n" +unless $sock; printf "%s\n", "SUCCESS: Port Responded" if $s +ock; close($sock) if $sock; } close $ssh_fh; exit; redo; } close $data_fh; } close $info; exit

In reply to Re^2: socket checker in multiple hosts for multiple destination by Bams
in thread socket checker in multiple hosts for multiple destination by Bams

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.