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