DF in HTML

DF in HTML

am 17.08.2007 08:47:19 von Sonu

<> 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
------------------------------------------------------------ ---------------=
=AD-----------------|
Filesystem | size | used | avail | capacity| Mounted
on|
------------------------------------------------------------ ---------------=
=AD----------------
|
/dev/dsk/c0t8d0s0| 6.3G | 2.0G | 4.3G | 32% |/
|
------------------------------------------------------------ ---------------=
=AD----------------|
/xxx | 0K | 0K | 0K | 0% |/
proc |
------------------------------------------------------------ ---------------=
=AD-----------------|


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?

Re: DF in HTML

am 17.08.2007 10:16:09 von JT

sonu wrote:
> <> 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 "

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

This create a HTML table from the output of df.

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de

Re: DF in HTML

am 17.08.2007 10:31:13 von usenet

On Aug 16, 11:47 pm, sonu wrote:
> <> 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/DfP ortable.pm
and it will even work on Windows!


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

Re: DF in HTML

am 17.08.2007 15:08:33 von Sonu

On Aug 17, 1:31 pm, use...@DavidFilmer.com wrote:
> On Aug 16, 11:47 pm, sonu wrote:
>
> > <> 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
> 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!
>
> --
> The best way to get a good answer is to ask a good question.
> David Filmer (http://DavidFilmer.com)

Thank you for reply.
I will try it.

Re: DF in HTML

am 17.08.2007 15:25:55 von Sonu

On Aug 17, 1:31 pm, use...@DavidFilmer.com wrote:
> On Aug 16, 11:47 pm, sonu wrote:
>
> > <> 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
> 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!
>
> --
> The best way to get a good answer is to ask a good question.
> David Filmer (http://DavidFilmer.com)

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