> 
> I am trying to write a perl program but I keep getting errors and I was 
> wondering if you can give me some pointers that might help. The
program is 
> supposed to read from a file which has a list of server names then put 
> this names in an array. I then used a foreach loop that is supposed to 
> read each server name and execute this command: uname -r remsh $server. 
> This command is supposed to go to each server and then print out the 
> version of each server but this is the part of the program that I keep 
> getting errors on. This is the complete program that I have so far:
> 
> #!/usr/local/bin/perl
> 

use strict;
use warnings;

> print "\n";
> $data_file="testserv.txt";
> open(DAT, $data_file) || die("Could not open file!");

You will usually want to include $! in the error string for the above
error handling so that you know why the file failed to open. As a style
comment if you use the 'or' operator you can drop the parens around 'open'.

open DAT, $data_file or die "Could not open file: $!";

> @raw_data=<DAT>;
> close(DAT);
> print "\n";
> foreach $server (@raw_data){
> remsh $server uname -r;

What is 'remsh'? This is not a Perl built in. I suspect this is your issue.

}
> 
> Please let me know what is the best way to go from server to server and 
> obtain the necessary information in a perl program.
> Thanks a lot !!!!!
> 

This is going to depend on the environment, and what server software is
available.  To run a program such as 'uname' on the server you are going
to need to be at a shell, a couple of options for that would be to use
the Net::Telnet or Net::SSH::Perl modules to open a remote session, but
again that depends on having those services running on the remote
server, having an account, etc.  There really is no best way, it is
completely environment dependent, and hopefully someone is dictating
your design.

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to