Passing complex commands with ssh is problematic, because there are two shells that evaluate the script: one on the local host and one on the remote host.
Save the script on the local host, and pass it via stdin to the remote shell:
The -s option allows to place script arguments
Thanks, its working perfect. Can you tell me how to get the count of the logs . What field do i need to edit in the below code.
Now i have another logfile where the timestamp in logs are displayed in a different manner as
This should output the result for last line only as Time currently in india is 17:51 and it is the only string Matching "Exception Found" in the last 3 hours.
How to modify the script propsed earlier to do this?
---------- Post updated 09-17-14 at 01:14 AM ---------- Previous update was 09-16-14 at 07:22 AM ----------
Given the help you have already received, why don't you show us what you have tried on your own to solve this slightly different problem?
The UNIX and Linux Forum is not a place to get free programming services every time you decide to change your requirements. We want you to learn from the examples we provide so you can do it yourself the next time.
Given the help you have already received, why don't you show us what you have tried on your own to solve this slightly different problem?
The UNIX and Linux Forum is not a place to get free programming services every time you decide to change your requirements. We want you to learn from the examples we provide so you can do it yourself the next time.
Thanks ,ill try to script this myself. I need some help understanding the below line.
What exactly is the function of Sprintf function and why is it in the order of D[3],D[1],D[2] instead of D[3],D[2],D[1] . If we are comparing the current timestamp (date +"%y%m%d%H%M" -d"- 3 hour") against the timestamp in logs, after splitting the timestamp in logs, it should be in order of yy/mm/dd as well.
---------- Post updated at 06:39 AM ---------- Previous update was at 06:38 AM ----------
Please ignore the above. I just realized my mistake. It will be D[3],D[1],D[2] only.
---------- Post updated at 07:54 AM ---------- Previous update was at 06:39 AM ----------
I modified the script as below and its working fine for the new File
... ... ...
I modified the script as below and its working fine for the new File
Congratulations! We are always glad to hear that the people who have come to The UNIX and Linux Forums are learning how to write code that works after getting help with the basics from the volunteers here.
And thank you for posting your working code; you are now one of the volunteers showing others how you solved your problem.
This User Gave Thanks to Don Cragun For This Post:
So basically I have a log file and each line in this log file starts with a timestamp:
MON DD HH:MM:SS
SEP 15 07:30:01
I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Hi Gurus,
I have a software which logs event in the log file and it has become to big to search into it.
I want to display all the lines from the log files between
<Jul 21, 2016 3:30:37 PM BST> to <Jul 21, 2016 3:45:37 PM BST>
that is 15 min data .
Please help
Use code tags, thanks. (10 Replies)
Hello ,
I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by
EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt
Contents of... (6 Replies)
I have a file like this
-rwxr-xr-x 1 rewq other 168 Jan 13 07:05 check_files.sh
I want to compare (check_files.sh time) with the current time to see if its is older than 2 hours or not
if it is not older than 2 hrs then do something.can someone help me on this?.I dont... (7 Replies)
I was looking at this script which outputs the two lines which differs less than one sec.
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
use constant SEC_MILIC => 1000;
my $file='infile';
## Open for reading argument file.
open my $fh, "<", $file or die "Cannot... (1 Reply)
Hi,
In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date×tamp. I have to figure out the the data is a date or time stamp or date×tamp.
If it is date then append "<space>00:00:00"... (1 Reply)
Hi All,
I am new to unix programming. I am trying for a requirement and the requirement goes like this.....
I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
I am doing this in my script ..
currenttimestamp=`db2 "select current timestamp from SYSIBM.SYSDUMMY1 with ur"`
echo s $currenttimestamp
but this is how its shows
s 1 -------------------------- 2011-04-18-12.43.25.345071 1 record(s) selected.
How can I just get the timestamp... (6 Replies)
Hello to all.
I work at AIX system without perl installed and I am restricted user, so I am limited to bash. In script that I am writing, I have to read line from file and transform date that I found inside to Unix timestamp. Line in file look something like this:
Tue Mar 29 06:59:00... (5 Replies)
I'm trying to compare 2 dates between current time and the timestamp on a file.
The date format is mmdd
Both return Apr 1 but when using if statement
line 11: Apr 1: command not found error is returned
#!/bin/sh
log="DateLog"
Current_Date=`date +%b%e`
Filepmdate=`ls -l /file.txt |... (1 Reply)