in reply to Unix Perl and Html

Greetings,

This might give you an outline to get started. It's a fairly nasty and rapidly punched in piece of code, so improvements are certainly required.

#!/usr/bin/perl -wT use strict; use CGI 'header'; my $data = `sudo printstatus`; open(LOG, '>> some.log.file') || die "Badness: $!\n"; print LOG $data, "\n\n", '=' x 75, "\n\n"; close(LOG); print header; print "<HTML><HEAD><TITLE>sudo printstatus</TITLE></HEAD>\n"; print "<H2>sudo printstatus</H2>\n<PRE>"; open(READLOG, 'some.log.file') || die "Badness: $!\n"; while (<READLOG>) { s/</&lt;/g; s/>/&gt;/g; print; } close(READLOG); print "</PRE></BODY></HTML>\n";

Of course, you can also parse the output of your command and put it into a nice looking table or something. Also, this only logs stuff when the user actually accesses the CGI. Also, it appends the new data to the end of the log rather than the beginning. That might be annoying for longer files.

-gryphon
code('Perl') || die;

Replies are listed 'Best First'.
Re: Re: Unix Perl and Html
by meccaxlr (Initiate) on Aug 16, 2001 at 17:56 UTC
    And a many thanks to you too gryphon monk ! My boss told me that the sudo thing was a bad idea because of security loopholes,(a mistake on my part) reading in from three dumpfiles in /usr/lsys/printstatus would be a better idea because its the output of sudo printstatus anyways. what would be a good way to do this. and i've looked at the dump files and they are a night mare, how would i parse them, i'm still a beginner any online resources for parsing? Thanks alot. your imput is greatly appreciated.

      Greetings meccaxlr,

      I'd be happy to help you, but I'm going to need to see some examples of the three files you're talking about. Also, how do you want them to be displayed? Who's your audience? That'll make a big difference. Also, and more importantly, what are folks looking at this report going to use it for? What are they wanting to learn from it?

      If you answer those questions and post short examples of the three files, I'm sure we can come up with something extra nifty-spiffy.

      -gryphon
      code('Perl') || die;