This question is mainly for the UNIX users out there...I need to write a program that will display all the configurable kernal parameters on a system, show their formula, and show their resolved value. what I have so far is below, but to explain it first, I run
kmtune -S /stand/system and throw it into an array to get all the parameters I need, and it displays the formula for them if any....the hexidecimal values are no problem, along with evaluating simple formulas...where I run into a snag is when a formula relys on the result of another parameter. I guess I dont understand enough about how to get around this to be able to explain it correctly, but if you know what kmtune's output looks like, you will see where I am running into a snag...here is what I got so far..
#!/usr/local/bin/perl
chomp(@datafile = `/usr/sbin/kmtune -S /stand/system`);
foreach (@datafile)
{
tr/[A-Z]/[a-z]/;
($key,$value) = split(/\s+/);
if ($key eq "Parameter" || $value eq "") { next; }
if (grep/^0x/i,$value) { $value = hex($value); }
$var{$key} = $value;
}
foreach $key(keys %var)
{
### Evaluating the hash variable generates errors on the ones that hav
+e varibales embedded in them.
#print "$key:", eval $var{$key}, "\n";
### This works, but doesnt resolve formulas in the variables.
print "$key:", $var{$key}, "\n";
}
Any help or ideas would be greatly appreciated...and if there is another way to get the formulas AND the end result, that would work, but I would prefer to find a nifty perly way to do it :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.