singho has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl #use strict; use warnings; # Checking details of the host. Domainname and the OS version will be +checked. my $SSH = '/usr/bin/ssh -o StrictHostKeyChecking=no' ; my $DOMAIN = '/bin/domainname'; my $LINUXOS = 'cat /etc/redhat-release'; my $UNIXOS = '/bin/uname -sr'; print "Enter the filename: "; chomp($HOSTLIST = <STDIN>); open HOSTS, $HOSTLIST or die "can't open the file: $!\n" ; foreach my $host (<HOSTS>) { chop($host); # if i do not use chop, ? comes in the ssh command. @details = qx($SSH $host $DOMAIN; $LINUXOS); print @details; }
1. Please help me to run the commands in one ssh session only, i know other way to do it by creating another script and calling it from the ssh command, but don't want like that.
2. How can i put checks while logged into the system and runnign the command, for particular system(in my case Linux/Solaris).
3. How the formatting of the output can be done, instead of it coming line by line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check host
by sauoq (Abbot) on May 11, 2012 at 19:44 UTC | |
|
Re: Check host
by pklausner (Scribe) on May 11, 2012 at 15:17 UTC | |
|
Re: Check host
by bulk88 (Priest) on May 12, 2012 at 16:12 UTC |