Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: How can I run ?

by aardvark (Pilgrim)
on Mar 24, 2001 at 09:49 UTC ( #66838=note: print w/ replies, xml ) Need Help??

in reply to How can I run ?

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

Comment on Re: How can I run ?
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://66838]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-07-12 21:09 GMT
Find Nodes?
    Voting Booth?

    When choosing user names for websites, I prefer to use:

    Results (241 votes), past polls