J
jammer
I am trying to write a script that takes a list of hosts and sshs into
the first one and then can ssh to other ones. I can only ssh to the
other hosts from the first host.
Here is what I tried:
I think it is waiting for the ssh to the first host to finish.
I guess I could scp a partial hostlist and a program to *.domain and
then run the program remotely.
Am I on a right track?
#!/bin/perl
use strict;
open( HL, '<hostlist3.txt' ) || die "can't open hostlist3";
#!/bin/perl
use strict;
open( HL, '<hostlist3.txt' ) || die "can't open hostlist3";
my $newCC;
my $line;
while ($line = <HL>) {
chop $line;
if ($line eq '') {
$newCC = 1;
}
if ($newCC == 1) {
if ($line ne '') {
$newCC = 0;
print "ssh $line\n";
# print `ssh $line`;
}
} else {
print "ssh $line uname -a\n";
# print`ssh $line uname -a`;
}
}
close( HL );
For example, if hostlist3.txt contains:
host1.domain
host2
host3.domain
host4
I need to ssh into host1.domain to ssh to host2
Then I need to ssh to host3.domain ro ssh to host4
The goal is to run 'uname' on a bunch of machines that are only
accessible from the *.domain machine.
The machine running the program can access all the *.domain machines
but not the others.
the first one and then can ssh to other ones. I can only ssh to the
other hosts from the first host.
Here is what I tried:
I think it is waiting for the ssh to the first host to finish.
I guess I could scp a partial hostlist and a program to *.domain and
then run the program remotely.
Am I on a right track?
#!/bin/perl
use strict;
open( HL, '<hostlist3.txt' ) || die "can't open hostlist3";
#!/bin/perl
use strict;
open( HL, '<hostlist3.txt' ) || die "can't open hostlist3";
my $newCC;
my $line;
while ($line = <HL>) {
chop $line;
if ($line eq '') {
$newCC = 1;
}
if ($newCC == 1) {
if ($line ne '') {
$newCC = 0;
print "ssh $line\n";
# print `ssh $line`;
}
} else {
print "ssh $line uname -a\n";
# print`ssh $line uname -a`;
}
}
close( HL );
For example, if hostlist3.txt contains:
host1.domain
host2
host3.domain
host4
I need to ssh into host1.domain to ssh to host2
Then I need to ssh to host3.domain ro ssh to host4
The goal is to run 'uname' on a bunch of machines that are only
accessible from the *.domain machine.
The machine running the program can access all the *.domain machines
but not the others.