On Tuesday 28 Oct 2003 7:20 pm, you wrote:
> Gary,
>
>    While your structure make sense. I'm a little lost here.
>
>    Do you mind given me the basic on the my %whichos
>
>    I don't think I've ever come across this before and need some
>    Explaination on that.
>
>    Thanks
> Phillip
>
[snip]
>
> 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);
> }

What I'm doing here, is using a list of regex's (actually, in this case 
they're simply substrings), that I will compare with a given variable within 
a loop.  Once I find a match, I use that regex to access a hash which 
contains the key to the hash I really want to access.

In this way, I can compare the header returned from the Net::telnet to find 
the OS I want, and then use that to access the hash within the hash of 
commands.

You won't actually need this because you're calling 'uname -s' to select it.


> 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]

Reply via email to