in reply to Re^3: socket checker in multiple hosts for multiple destination (Perl 6)
in thread socket checker in multiple hosts for multiple destination

Use of uninitialized value $servername in printf at ./new.pl line 42. This is the error message I am getting when I executed the code after modifying change suggested by "poj" Please help. Any guidance would be greatly appreciated

  • Comment on Re^4: socket checker in multiple hosts for multiple destination (Perl 6)

Replies are listed 'Best First'.
Re^5: socket checker in multiple hosts for multiple destination (Perl 6)
by poj (Abbot) on Feb 16, 2016 at 08:44 UTC

    Use this basic program to check your input files

    #!/usr/bin/perl use strict; use Data::Dumper; $Data::Dumper::Useqq = 1; if( @ARGV < 2 ) { print "Usage: new.pl source destination\n"; exit; } my $file1 = $ARGV[0]; my $file2 = $ARGV[1]; open my $fh1,'<',$file1 or die "Could not open $file1: $!"; my @src = <$fh1>; chomp(@src); close $fh1; open my $fh2,'<',$file2 or die "Could not open $file2: $!"; my @dest = <$fh2>; chomp(@dest); close $fh2; # check data print Dumper(\@src,\@dest); for my $src (@src){ print "Source [$src]\n"; for my $dest (@dest){ my ($servername, $portnumber) = split ',', $dest; print "Destination [$servername:$portnumber] \n"; } }
    poj

      Hi POJ, Thanks for your response.

      $: cat source.csv 123.com 456.com 789.com $: cat destination.csv bc.com,3080 def.com,4560 $: ./new2.pl source.csv destination.csv $VAR1 = [ "123.com", "456.com", "789.com" ]; $VAR2 = [ "bc.com,3080", "def.com,4560" ]; Source [123.com] Destination [bc.com:3080] Destination [def.com:4560] Source [456.com] Destination [bc.com:3080] Destination [def.com:4560] Source [789.com] Destination [bc.com:3080] Destination [def.com:4560]
      Here is the output of the program you gave . This works fine, the problem occurs when I try to connect to remote server and execute that socket, the result doesn't stop printing. It goes into endless loop.

        Hi Bams,

        Please edit your post to show your command line output inside <code></code> tags, like you did with your script.

        Your infinite loop problem is likely because you have the line:

        redo;
        in your while block.

        Hope this helps!


        The way forward always starts with a minimal test.