DF in HTML

S

sonu

<<df>> is disk free command in Unix. I am using Sun OS 5.9. When
executed df command i get output like
[XXX@XXXXdb:~]#df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t8d0s0 6.3G 2.0G 4.3G 32% /
/xxx 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
fd 0K 0K 0K 0% /dev/fd
swap 948M 104K 947M 1% /var/run
swap 2.1G 1.2G 947M 57% /tmp
/dev/dsk/YYY 8.3G 4.2G 4.0G 52% /export/home/u01
/dev/dsk/YYY 8.3G 1.7G 6.5G 22% /export/home/u02
/dev/dsk/YYYY 8.3G 3.3G 5.0G 40% /export/home/u03

i want this output to come in html formate
so on mail it will look like
---------------------------------------------------------------------------­-----------------|
Filesystem | size | used | avail | capacity| Mounted
on|
---------------------------------------------------------------------------­----------------
|
/dev/dsk/c0t8d0s0| 6.3G | 2.0G | 4.3G | 32% |/
|
---------------------------------------------------------------------------­----------------|
/xxx | 0K | 0K | 0K | 0% |/
proc |
---------------------------------------------------------------------------­-----------------|


basically in row column format like we see a table on html page.


I know how to mail it but i don't know how to change this text output
from df to an html page.


step 1 will be
df > 123
then how to change and replace the text each and every time using
program?
 
J

Jens Thoms Toerring

sonu said:
<<df>> is disk free command in Unix. I am using Sun OS 5.9. When
executed df command i get output like
[XXX@XXXXdb:~]#df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t8d0s0 6.3G 2.0G 4.3G 32% /
/xxx 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
fd 0K 0K 0K 0% /dev/fd
swap 948M 104K 947M 1% /var/run
swap 2.1G 1.2G 947M 57% /tmp
/dev/dsk/YYY 8.3G 4.2G 4.0G 52% /export/home/u01
/dev/dsk/YYY 8.3G 1.7G 6.5G 22% /export/home/u02
/dev/dsk/YYYY 8.3G 3.3G 5.0G 40% /export/home/u03
i want this output to come in html formate
so on mail it will look like
---------------------------------------------------------------------------?-----------------|
Filesystem | size | used | avail | capacity| Mounted
on|
---------------------------------------------------------------------------?----------------
|
/dev/dsk/c0t8d0s0| 6.3G | 2.0G | 4.3G | 32% |/
|
---------------------------------------------------------------------------?----------------|
/xxx | 0K | 0K | 0K | 0% |/
proc |
---------------------------------------------------------------------------?-----------------|
basically in row column format like we see a table on html page.
I know how to mail it but i don't know how to change this text output
from df to an html page.
step 1 will be
df > 123
then how to change and replace the text each and every time using
program?

You don't need to write the output of df to a file, you can start
it with it's stdout redirected to a pipe to the perl script and
the read in it's output and immediately convert it in the script:

use strict;
use warnings;

open my $f, "df -h |" or die "Can't run 'df -h'.\n";

print "<table>\n";
while ( <$f> ) {
print "<tr>\n";
for my $field ( split /\s+/ ) {
print "<td>$field</td>\n",
}
print "</tr>\n";
}
print "</table>\n";
close $f;

This create a HTML table from the output of df.

Regards, Jens
 
U

usenet

<<df>> is disk free command in Unix. I am using Sun OS 5.9.

But it's not controlled by any sort of standards, so the output can be
different on other systems (or even if you upgrade your own system).
And sometimes the output can change if strange things happen (very
large filesystems get added, etc). Parsing the output of system
commands can be risky and failure-prone.

I recommend that you access this information using a Perl module such
as http://search.cpan.org/~iguthrie/Filesys-Df-0.92/Df.pm, which will
allow your program to work on practically any flavor of *NIX for all
eternity.

Or you can use http://search.cpan.org/~iguthrie/Filesys-DfPortable-0.85/DfPortable.pm
and it will even work on Windows!
 
S

sonu

But it's not controlled by any sort of standards, so the output can be
different on other systems (or even if you upgrade your own system).
And sometimes the output can change if strange things happen (very
large filesystems get added, etc). Parsing the output of system
commands can be risky and failure-prone.

I recommend that you access this information using a Perl module such
ashttp://search.cpan.org/~iguthrie/Filesys-Df-0.92/Df.pm, which will
allow your program to work on practically any flavor of *NIX for all
eternity.

Or you can usehttp://search.cpan.org/~iguthrie/Filesys-DfPortable-0.85/DfPortable.pm
and it will even work on Windows!

Thank you for reply.
I will try it.
 
S

sonu

But it's not controlled by any sort of standards, so the output can be
different on other systems (or even if you upgrade your own system).
And sometimes the output can change if strange things happen (very
large filesystems get added, etc). Parsing the output of system
commands can be risky and failure-prone.

I recommend that you access this information using a Perl module such
ashttp://search.cpan.org/~iguthrie/Filesys-Df-0.92/Df.pm, which will
allow your program to work on practically any flavor of *NIX for all
eternity.

Or you can usehttp://search.cpan.org/~iguthrie/Filesys-DfPortable-0.85/DfPortable.pm
and it will even work on Windows!

WOW i got my output thanks A ton.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top