# Create array @hosts...  So far so good.
my @hosts=qw( lunar solar venus mars saturn pluto );

# \@hosts creates a reference to @hosts.  You just want @hosts.
#
# The way you've written it, the elements in @hosts will be
# assigned to the special variable $_.  This is all right, but
# tends to get confusing, especially for non-veterans.  It may
# even cause problems down the line if you forget you are
# already using $_ and nest another loop that uses it.  Instead
# try declaring your variable as I show below.
#
# Also foreach -> for.  I think it reads better.
#
for my $host (@hosts) {
    # system("/usr/bin/ssh @hosts $ARGV[0]");
    # @hosts is still the array.  You want $_ or $host, see above.
    system("/usr/bin/ssh $host $ARGV[0]");
}



dan radom wrote:

>Hi,
>
>
>I've got a problem with the following code...
>
>my @hosts=qw( lunar solar venus mars saturn pluto );
>
>foreach (\@hosts) {
>        system("/usr/bin/ssh @hosts $ARGV[0]");
>}
>
>....
>
>What I'm wanting to do is call foo.pl uname (for example) and have the script ssh 
>host uname for each host defined in the @hosts array.  What's currently happening is 
>that it does ssh lunar solar and dies trying to execute the next @hosts as the ssh 
>commend.  Any ideas?
>
>dan
>




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to