- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Basic perl script
Operating System - Linux
1753449
Members
6132
Online
108794
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 09:16 PM
06-22-2006 09:16 PM
Re: Basic perl script
Just How I would write it ...
--8<---
#!/usr/bin/perl
use strict; # Never write without it
use warnings; # Shows you what you wanted to know
my $html_file = "/var/apache/htdocs/tmp1.html";
unlink $html_file;
open my $html, ">", $html_file or die "$html_file: $!";
foreach my $ifile (glob "/var/apache/htdocs/cfg/*.cfg") {
print STDERR "$ifile ...\n";
local (@ARGV, $/) = ($ifile);
$lines = <>;
(my $dist_name = $ifile) =~ s{.*/[^/]+.cfg$}{$1};
print $html << EOH;
Welcome to Infoman Report Centre
<meta http-equiv="refresh" content="60#" />
< circle="" outside="">
MRTG Statistics for Distribution $dist_name
EOH
while ($lines =~ m{^Target(.*?)}mgs) {
my $stanza = $1;
my ($url) = $stanza =~ m{\[(.*?)\].*};
my ($desc) = $stanza =~ m{.*Description:(.*?).*}i;
print $html qq{Desc: $desc\n",
\n";
print STDERR "-" x 40, "\n";
}
}
print $html "\n\n";
close $html;
-->8---
Though I have serious doubt about this whole script.
I have already altered you HTML generation, as it was very wrong. Mine still isn't w3c compliant, but I have removed several parts already.
You are generating a single html file with several starts, each had two calls in your original,
inside a section and much more.
Have a look at the final outcome, and see if this is really what you want. I hope it's not.
Enjoy, Have FUN! H.Merijn
--8<---
#!/usr/bin/perl
use strict; # Never write without it
use warnings; # Shows you what you wanted to know
my $html_file = "/var/apache/htdocs/tmp1.html";
unlink $html_file;
open my $html, ">", $html_file or die "$html_file: $!";
foreach my $ifile (glob "/var/apache/htdocs/cfg/*.cfg") {
print STDERR "$ifile ...\n";
local (@ARGV, $/) = ($ifile);
$lines = <>;
(my $dist_name = $ifile) =~ s{.*/[^/]+.cfg$}{$1};
print $html << EOH;
<meta http-equiv="refresh" content="60#" />
< circle="" outside="">
MRTG Statistics for Distribution $dist_name
EOH
while ($lines =~ m{^Target(.*?)}mgs) {
my $stanza = $1;
my ($url) = $stanza =~ m{\[(.*?)\].*};
my ($desc) = $stanza =~ m{.*Description:(.*?).*}i;
print $html qq{Desc: $desc\n",
\n";
print STDERR "-" x 40, "\n";
}
}
print $html "\n\n";
close $html;
-->8---
Though I have serious doubt about this whole script.
I have already altered you HTML generation, as it was very wrong. Mine still isn't w3c compliant, but I have removed several parts already.
You are generating a single html file with several starts, each had two calls in your original,
inside a section and much more.
Have a look at the final outcome, and see if this is really what you want. I hope it's not.
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP