Below is a perl code I am trying.
#!/usr/bin/perl
#use strict;
use warnings qw/ all FATAL /;
use constant ENV_FILE => '/apps/env_data.txt';
$uenv = $ARGV[0];
my $input = $uenv;
open my $fh, '<', ENV_FILE
or die sprintf qq{Unable to open "%s" for input: $!}, ENV_FILE;
LINE:
while ( <$fh> ) {
next unless /\S/;
my ($env, $dir, $servers) = split;
next unless $env eq $input;
for my $server ( split /,/, $servers ) {
## Connect to $server and access $dir
system "ssh $server 'cat $dir/server.properties'";
last LINE;
}
}
cat /apps/env_data.txt
qa1 /apps/8801/conf qavm01,qavm02,qavm03
qa2 /apps/8901/conf qavm01,qavm03,qavm04
qa3 /apps/8701/conf qavm01,qavm04,qavm02
cpc /apps/19100/conf cpcint101
cpc2 /apps/19101/conf cpcint02
for some reason the script is connecting to only $server out of the $servers to display the value. Any thoughts on it? I am still learning perl. So I might be making silly mistakes.