All pastes #267230 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-04 18:35 UTC
rendered paste body
Goal: Create an html table from the output of PS.
I imagine it would go something like this:

#!/bin/bash
array=($(ps au))
for element in "${array[@]}";
do 

# Ideally the following line would be iterated until all of my tables were created conatining the PS values.
echo '<html><table><tr>  <td>${array[@]}</td>  <td>${array[@]}</td> <td>${array[@]}</td> <td>${array[@]}</td><tr>';

done 
# Since the done has been declared does this mean that it will only output the first 4 variables? I need all variables output into the above "format" so I can get the entire PS output into a table.

echo '</table></html>';
# Finish off my wonderful table of PS to place into a site.

#Example output of html table
[ root ]     [ 4438 ] [ 0.0 ] [ 3.0 ]  [ 1566 ]  [ /sbin/getty ]
[ root ]     [ 4438 ] [ 0.0 ] [ 0.0 ]  [ 1567 ]  [ /sbin/getty ]
[ root ]     [ 4438 ] [ 0.0 ] [ 5.0 ]  [ 1562 ]  [ /sbin/getty ]