User Profile

Collapse

Profile Sidebar

Collapse
joeferns79
joeferns79
Last Activity: Jan 21 '14, 08:32 PM
Joined: Sep 10 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • joeferns79
    replied to Reading from a directory fails
    in Perl
    Thanks, Ron! I appreciate it.
    See more | Go to post

    Leave a comment:


  • joeferns79
    started a topic Reading from a directory fails
    in Perl

    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";
    ...
    See more | Go to post

  • joeferns79
    replied to Extract lines from a file
    in Perl
    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.
    ...
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to Extract lines from a file
    in Perl
    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;
    ...
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to Print to a file instead of to the screen
    in Perl
    Thanks, Jeff. Don't know how I missed that.
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to Extract lines from a file
    in Perl
    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;
    ...
    See more | Go to post

    Leave a comment:


  • joeferns79
    started a topic Print to a file instead of to the screen
    in Perl

    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
    ...
    See more | Go to post

  • joeferns79
    started a topic Extract lines from a file
    in Perl

    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:
    ...
    See more | Go to post

  • joeferns79
    replied to String manipulation for a date
    in Perl
    Thanks, Kevin. Appreciate it.
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to String manipulation for a date
    in Perl
    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...
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to String manipulation for a date
    in Perl
    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);
    ...
    See more | Go to post
    Last edited by numberwhun; Aug 22 '09, 01:05 PM. Reason: Please use square brackets for code tags, not angle brackets

    Leave a comment:


  • joeferns79
    replied to Date Manipulation
    in Perl
    Thanks a lot, that worked.
    See more | Go to post

    Leave a comment:


  • joeferns79
    started a topic Date Manipulation
    in Perl

    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.
    See more | Go to post

  • 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.
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to String manipulation for a date
    in Perl
    Man, you truly are an Expert, aren't you? :-)
    See more | Go to post

    Leave a comment:


  • joeferns79
    replied to String manipulation for a date
    in Perl
    What would the regular expression look like?
    See more | Go to post

    Leave a comment:


  • joeferns79
    started a topic String manipulation for a date
    in Perl

    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
    ...
    See more | Go to post

  • Thanks, I got it working once I removed the "\n". I was actually testing it out and forgot to remove it earlier. Thanks, again.
    See more | Go to post

    Leave a comment:


  • I 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 {
    ...
    See more | Go to post
    Last edited by eWish; Jun 23 '09, 04:11 AM. Reason: Fixed code tags [code][/code]

    Leave a comment:


  • That 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",
    ...
    See more | Go to post
    Last edited by eWish; Jun 23 '09, 04:10 AM. Reason: Fixed code tags [code][/code]

    Leave a comment:

No activity results to display
Show More
Working...