I wrote this a while back to check out the disk space (df) on a Linux box, maybe this will help you out ...

In my first page (system.cgi);

<a href="system_process.cgi?action=df">Free Hard Disk Space</a>
In the second page (system_process.cgi)
I get the 'action' parameter;
my $action = $cgi->param('action') || 'default';

Later in the second page;

print <<"END"; <h1>System Administration</h1> <table width="450" valign="top" border="0"> <tr> </td> <td width="400" valign="top" align="left"> END if ($action eq 'df' ) { my ($headers_ar, $df_result_ar) = &MySystem::get_df; # print out the table headers print "<table><tr>\n"; foreach my $t_head ( @$headers_ar ) { print "<th>$t_head</th>\n"; } # end table header print "</tr>\n"; foreach my $hold_ar (@$df_result_ar) { print "<tr>"; foreach (@$hold_ar) { print "<td>$_</td>"; } print "</tr>"; } # end table print "</table>\n"; } print <<"END"; </td> </tr> </table> END
Here is the &MySystem::get_df routine;
sub get_df { my (@headers,@rows); # put each line the command returns into an array my @df = `df -Ph`; # the first element of the array contains the headers my $temp_df = shift @df; @headers = split (/\s+/, $temp_df); foreach (@df) { my @parsed_row = split (/\s+/, $_); unshift @rows, \@parsed_row; } return (\@headers, \@rows); }
The hardest part is figuring out exactly what the command is returning and putting it into a data structure. Then use the data structure to display it. I hope this helps, good luck.

Get Strong Together!!


In reply to Re: How can I run ? by aardvark
in thread How can I run ? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.