AcidHawk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am running ASPerl 5.6.1 on Windows 2000 using Apache as the web server. I need a quick solution to display a page while our production Helpdesk has it's legs in the air. This solution may need to be used again in the future, so I would like to start with a quick win but expand this into something more a little later.
The Problem: I have an automated process that creates small xml files in several dirs. These files can number upwards of 200 files per dir and about 7 dirs.
home/ | |
dirA/ | |
dirB/ | |
dirC/ |
Each XML file looks similar to the following:
<?xml version="1.0"?> <opt> <Agent_Class>Backup</Agent_Class> <MD>dirA</MD> <Agent_Instance>NetBackup</Agent_Instance> <Date>2003/12/08</Date> <Server>ServerABC</Server> <Instance_Detail>Backup Problems ServerABC:57</Instance_Detail> <Time>08:04:58</Time> <Header>X-CALL</Header> <State>CRITICAL</State> </opt>
Basically I need to display a table with the dir name and some of the contents of all the files in its dir. Something like:
Managing Server | Call Details |
dirA | |
ServerABC - Backup - NetBackup - Backup Problems ServerABC:57 | |
ServerDEF - Drive - Space - Drive C: is out of disk space |
I thought of putting all the data from the files into a hash so I only had to process the relevant bits when I build the web page.if (opendir (DIR, $path)) { while( my $dir = readdir( DIR ) ) { next if( ( "." eq $dir ) || ( ".." eq $dir ) ); if (-d "$path/$dir") { print "<TR><TD>$dir</TD><TD></TD></TR>\n"; print "<TR><TD>$dir</TD>\n"; if (opendir (CUSTDIR, "$path/$dir")) { my $count = 0; while (my $file = readdir( CUSTDIR)) { next if (("." eq $file) || (".." eq $file)); $count++; if (eval { $callvals = XMLin("$path/$dir/$file") } +) { # $calldetails{$callvals->{Server}} = "$callval +s->{State} $callvals->{Agent_Class} $callvals->{Agent_Instance} $call +vals->{Instance_Detail}"; print "<TR><TD></TD><TD><B>$callvals->{Server} +</B> - $callvals->{State} - $callvals->{Agent_Class} - $callvals->{Ag +ent_Instance} - $callvals->{Instance_Detail}</TD></TR>\n"; } else { die "Cannot Read $path/$dir/$file: $@\n"; } } close (CUSTDIR); print "<TD>$count XML files</TD></TR>\n"; } else { die "Cannot find path $path/$dir: $!\n"; } } } close(DIR); } else { die "Cannot find path $path: $!\n"; }
What can I do to be able to read these files and put some of the detail in a web page before the web page times out or tries to refresh itself (120 Secs)?
It must be said that I am using CGI, but that cgi/html is NOT where my little experience lies..
-----Of all the things I've lost in my life, its my mind I miss the most.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Fast processing of XML files for CGI
by inman (Curate) on Dec 08, 2003 at 10:51 UTC | |
by inman (Curate) on Dec 08, 2003 at 11:22 UTC | |
Re: Fast processing of XML files for CGI
by Roger (Parson) on Dec 08, 2003 at 13:16 UTC | |
Re: Fast processing of XML files for CGI
by CountZero (Bishop) on Dec 08, 2003 at 23:10 UTC | |
by AcidHawk (Vicar) on Dec 09, 2003 at 05:54 UTC | |
Re: Fast processing of XML files for CGI
by CountZero (Bishop) on Dec 08, 2003 at 23:15 UTC |