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 2281 numberwhun 3,509
Recognized Expert Moderator Specialist @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 programm execution.
I would like to echo the complete console output into a textfile and
send this file as email at a certain point in time.
The programm execution shall not be stopped.
|
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 "window.print".
|
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
The ScreenplayCSS is flawed, for several reasons;
-overuse of <div id= tags
-doesn't scale screen resolutions (convert from px to in, pt ?)
-no media="print" (how much coule be shared between "screen" & "print")
-no automatic page breaks (with...
|
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 going to explain what I would like to do.
Clicking on the print button I would like to show immediately the print
dialog without open a new window with the text formatted for printing.
|
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 to a file (in the printer selection
screen of the print routines) it gives me a file named what I wanted, but is
just garbage. Can't read it.
TIA
ron
| |
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 contains an
email, including all the html coding. Most email have just a few
lines of actual text, but with all the html stuff (<doctype><body
bgColor></Div><Bodyetc.), it usually fills up most of the screen.
Problem is, whenever the content of a...
|
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 Perl Builder which is
an Integrated Development Environment for Perl scripting.
I am trying to access the data in a txt file and then print
the results to the screen.
The procedure for doing this is write a script then click on the
Run button,...
|
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 shot?
If so, how?
Thanks,
|
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.
For example...
If I have a style sheet specifying media="all," is the following correct
syntax to center text for printing, but not for screen presentation?
..divClass1 {
|
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 screen, when I open a file, the entire contents of the file is
in fact being shown...so why can't I print it later? All of this code
I am getting from a book (Chris Sells) and the net. The solution is
to be found in the fact that stringbuilder is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |