On Monday 27 Oct 2003 7:32 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I'm trying to accomplish some task using perl. So let
> me describe what I have.
>
> I have several systems of the following:
>
> Unix:
> Sun - Solaris
> HP - HPUX
>
> Windows:
> Dell - Windows 2k
>
> Each of these OS's have specific commands that are specific
> not only to the OS but to the hardware as well. Wouldn't it be
> better if I created a header file that contains these commands
> and assigned them to a common variable?
>
> Example:
> $memory = 'prtconf | grep Memory | awk '{print $3}'
>
[snip]
Hi Philip,
I'd try something like (asuming $detail is part of the header returned from
the Net::telnet connect)
my %whichos=('Solarix'=>'sol','Aix'=>'aix','microsoft'=>'W2K');
my %commands=('sol'=>{'memory'=>'prtconf | grep Memory | awk '{print $3}',
'diskfree'=>'..........'}
'aix'=>{'memory'=>'.......',
'diskfree'=>'......'}
'W2k'=>{'memory'=>'........',
'diskfree'=>'......'});
my $OS='';
foreach my $regex (keys %whichos) {
$OS=$whichos{$regex} if ($details=~/$regex/i);
}
die "cannot find OS" unless ( $OS && defined {$commands{$OS});
then simply use %commands{$OS}{memory} to get the command you want
>
> Phillip Bruce
> ISC Consultant, System Architect
> Location: Dublin, CA
> * Cell: 408-476-8658
> * Office: 925-560-7853
> AIM: OkieUnix
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]