I have the following code that prints to the screen but I want to print the lines to a file that I give as an argument to the script instead... -
#!/usr/bin/perl
-
-
use strict;
-
-
-
####################################################################
-
# constants
-
####################################################################
-
-
use constant COUNT => 0;
-
use constant MAX => 1;
-
use constant MIN => 2;
-
use constant TOTAL => 3;
-
use constant AVERAGE => 4;
-
use constant FCOUNT => 5;
-
use constant FMAX => 6;
-
use constant FMIN => 7;
-
use constant FTOTAL => 8;
-
use constant FAVERAGE => 9;
-
-
####################################################################
-
# genreport
-
####################################################################
-
-
sub genreport {
-
my ($logfile, $reportfile) = @_;
-
my ($line, $elapsed, $facade, %calls);
-
my (@fields, $count, $min, $max, $total, $average,$fcount,$fmin,$fmax,$ftotal,$faverage);
-
my (@list, $totalcalls);
-
my ($falseflag);
-
my ($statdate,$server);
-
my ($starttime,$error,$first);
-
-
open(LOGFILE, "<$logfile")
-
or die "Can't open $logfile: $!";
-
-
open(REPORTFILE, ">$reportfile")
-
or die "Can't open $reportfile: $!";
-
-
$totalcalls = 0;
-
while ($line = <LOGFILE>) {
-
chomp $line;
-
$falseflag= 0;
-
$statdate = substr($line,1,8);
-
$starttime = substr($line,9,12);
-
if($line =~ (/J2CA0027E/))
-
{
-
$falseflag = 1;
-
while ($line =<LOGFILE>){
-
if(($line =~(/_TH/)) || ($line =~ (/invokeMessageEndpointMethod/))) {
-
$line = substr($line,3,length($line));
-
printf "%s %s,%s\n",$statdate,$starttime,$line;
-
last;
-
}
-
}
-
}
-
}
-
}
-
####################################################################
-
# main
-
####################################################################
-
-
if (@ARGV != 2) {
-
die "usage: servercalls.pl <logfile> <reportfile>";
-
}
-
-
my ($logfile, $reportfile) = @ARGV;
-
-
genreport($logfile, $reportfile);
-
-
2 2275 @joeferns79
The problem I see is that you open the reportfile for writing, but you never reference the filehandle in the print statement. If you want the print statement to go to file, then it would have to look like this: -
printf REPORTFILE "%s %s,%s\n",$statdate,$starttime,$line;
-
Regards,
Jeff
Thanks, Jeff. Don't know how I missed that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Manfred Schwab |
last post by:
Recording messages and print statements in a textfile during program
execution.
Is there a similar command to redirect errormessages or print statements
into a standart asciifile during...
|
by: Yaron Cohen |
last post by:
Hi,
I would like to ask for your help.
I am using IE5.5.
I have a wide page with horizontal scroll bar.
The problem is that I get only 1 page when printing it using
"file->print" or...
|
by: David J Patrick |
last post by:
I'm trying to rewrite the CSS used in
http://s92415866.onlinehome.us/files/ScreenplayCSSv2.html.
using the w3.org paged media standards as described at
http://www.w3.org/TR/REC-CSS2/page.html
...
|
by: BELIUS |
last post by:
Hi all,
I am implementing a "Print this Page" function in my ASP.NET application.
This function should print a part of the page and I would like to use an
MSDN Style "Print this Page".
I'm...
|
by: Ron |
last post by:
Hi All,
Is it possible to have Access print a report, identical to one that would
print to a printer, only print to a "standard" text file? I can't find it
in help and when I try to just print...
|
by: stcalixte |
last post by:
First off, I really don't know much about Access, so please bear with
me. Here's my problem. I have an Access file containing about 15
columns and 600 rows. Each cell in one of the columns...
|
by: Max58kl |
last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window
--------------------------------------------------------------------------------
Hi
I am using a program called...
|
by: bdy120602 |
last post by:
Is it possible, when a user or viewer of your Web page, prints or
takes a screen shot of a Web page with mousover (roll-over) text in
it, to have that text printed or captures as part of the screen...
|
by: Ed Jay |
last post by:
I do not want to load two style sheets for screen and print media. I'm
having difficulty grasping the use of the @print statement, or its syntax.
Would someone please provide a simple explanation....
|
by: raylopez99 |
last post by:
I am running out of printing paper trying to debug this...it has to be
trivial, but I cannot figure it out--can you? Why am I not printing
text, but just the initial string "howdy"?
On the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |