User Profile
Collapse
-
Thanks, Ron! I appreciate it. -
Reading from a directory fails
I've got a script that's supposed to read files from a directory, and do pattern match on each file in the dir. If I run this script from within the dir that contains the files, it works fine but it fails to find any file if I run it from the parent dir.
Code:#!/usr/bin/perl use strict; use warnings; opendir my $DIR, '/home/tester1/logs/' or die "opendir .: $!\n"; print "$DIR\n";
-
Somehow, the line that's supposed to be printed just once is getting repeated 4 times, since the line with the "_TH" string is present in 4 locations under the stack trace.
i.e. the input log looks like this...
Code:[ERROR] [02 Sep 2009 11:33:17] [Trace] [WebContainer : 54] - infrastructure:ID_UNHANDLED: An un-handled server exception occu rred. Please contact your administrator.
Leave a comment:
-
Sorry, the one I made a change to was another script. Here's this one with the change....
Code:use strict; #################################################################### # constants #################################################################### use constant COUNT => 0; use constant MAX => 1; use constant MIN => 2;
Leave a comment:
-
-
Code: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;
Leave a comment:
-
Print to a file instead of to the screen
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...
Code:#!/usr/bin/perl use strict; #################################################################### # constants #################################################################### use constant COUNT => 0; use
-
Extract lines from a file
I have this log ...
Code:[ERROR] [02 Sep 2009 11:33:17] [Trace] [WebContainer : 54] - infrastructure:ID_UNHANDLED: An un-handled server exception occu rred. Please contact your administrator. at .util.internal.HandleException.getRemoteException(HandleException.java(Compiled Code)) at .util.internal.HandleException.getRemoteException(HandleException.java(Compiled Co nested exception is:
-
-
Kevin,
After changing my code I now get only the dates ...
2009-02-24-10.57.10.000000
2009-02-24-10.57.10.000000
2009-02-24-10.57.19.000000
2009-02-24-10.57.23.000000
2009-02-24-10.57.24.000000
2009-02-24-10.57.50.000000
2009-02-24-10.57.50.000000
2009-02-24-10.57.50.000000
2009-02-24-10.57.50.000000
2009-02-24-10.57.50.000000
2009-02-24-10.51.8.000000...Leave a comment:
-
Kevin,
I got the following code for this ...
Code:#!/usr/bin/perl $mystring = "20090216T131131"; print "The input is $mystring"; printf "\n"; @myarray = ($mystring =~ m/(\d+)/g); $result = join("", @myarray); my ($y,$m,$d,$h,$min,$sec) = unpack("A4A2A2Z2Z2Z2",$result); $done = sprintf ("%d-%2.2d-%d-%d.%d.%d.%06s",$y,$m,$d,$h,$min,$sec,0);
Last edited by numberwhun; Aug 22 '09, 01:05 PM. Reason: Please use square brackets for code tags, not angle bracketsLeave a comment:
-
-
Date Manipulation
Is there a way of getting the previous date when we enter a specific date?
e.g if we enter ... 20090804, it should return 20090803, or even if we enter a future date...20090910 , it should return 20090909. -
Icecrack, I was going through the forum and I noticed that you had posted a reply. I know it's like 2 months since you replied and I am not sure if you'll get this, but yes, it's a multi-line log.Leave a comment:
-
-
-
String manipulation for a date
A file contains the following contents ...
Code:20090224T105933 s990atap01 Statistics 0 curam.util.internal.workflow.intf.WorkflowQueueHandler.handleWorkflow EnactmentMessage ( java.lang.String java.lang.String java.lang.Long ) true 5608 20090224T105940 s990atap01 Statistics 0 curam.util.internal.workflow.intf.WorkflowActivityQueueHandler.handle ActivityMessage ( java.lang.String
-
joeferns79 replied to Searching files by matching filename pattern and concatenating contents of the filesin PerlThanks, I got it working once I removed the "\n". I was actually testing it out and forgot to remove it earlier. Thanks, again.Leave a comment:
-
joeferns79 replied to Searching files by matching filename pattern and concatenating contents of the filesin PerlI tried the following script as well, to no avail...
Code:#!/usr/bin/perl use POSIX 'strftime'; my $date = strftime("%Y%m%d", localtime(time - 86400)). "\n"; #print $date; $wldir="/usr/IBM/WebSphere/AppServer/logs/test"; #$wlarc=$wldir/$date; do_dir($wldir); sub do_dir {
Leave a comment:
-
joeferns79 replied to Searching files by matching filename pattern and concatenating contents of the filesin PerlThat worked fine, thanks.
I am now trying to include the output from that into a search for filenames containing yesterday's date.
Code:#!/usr/bin/perl $hostname=`hostname`; chomp($hostname); #$today=`perl -e 'print localtime(time() - 86400) . "\n"'`; #chomp($today); #!/usr/bin/perl use POSIX 'strftime'; my $date = strftime("%Y%m%d",
Leave a comment:
No activity results to display
Show More
Leave a comment: