- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Initiate a script for a pattern grepped in a f...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2012 11:36 PM
10-14-2012 11:36 PM
Hi ,
I want to initiate a script when the following pattern is obserevd in a file.
For ex:
file name is abclog
a pattern like " Start of x1 job" comes in this logfile ;
then my scrpt called xyz.sh must run till i get the following line in my logfile ;
"End of c2 job"
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2012 03:54 AM
10-15-2012 03:54 AM
Re: Initiate a script for a pattern grepped in a file
Do you want to invoke the script on the whole file but only process the lines between the Start and End?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2012 04:04 AM
10-15-2012 04:04 AM
scripting help reqd
Hi Dennis ,
Yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2012 04:25 AM
10-15-2012 04:25 AM
Re: Initiate a script for a pattern grepped in a file
>a pattern like " Start of x1 job" comes in this logfile ;
>till I get the following line in my logfile; "End of c2 job"
You can use awk (or sed) to extract out the part you want. You could either do it all in awk or pipe it to your script:
awk '/Start of x1 job/,/End of c2 job/ { print $0 }' abclog | your-script
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2012 05:40 AM
10-15-2012 05:40 AM
Re: Initiate a script for a pattern grepped in a file
Hi Dennis,
its dynamically updating file i dont know the exact time of this logfile.
how can we achive in such case ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2012 06:14 AM
10-15-2012 06:14 AM
Re: Initiate a script for a pattern grepped in a file
>its dynamically updating file I don't know the exact time of this logfile.
I'm not sure what you mean by dynamic? Do you mean that the End line may not be there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2012 07:42 AM
10-15-2012 07:42 AM
Re: Initiate a script for a pattern grepped in a file
tail +1 -f abclog | awk '/Start of x1 job/,/End of c2 job/ { print $0 }' | your-script
- Tags:
- tail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2012 03:38 AM
10-17-2012 03:38 AM
Re: Initiate a script for a pattern grepped in a file
Hi Dennis ,
Yes the file is say abclog .
it might contain any content in the day time.
And say at 9 pm mayb sudenly comes Start line and afetr 1 hr comes the END line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2012 03:52 AM - edited 10-17-2012 03:44 PM
10-17-2012 03:52 AM - edited 10-17-2012 03:44 PM
Solution>And say at 9 pm maybe suddenly comes Start line and after 1 hr comes the END line.
Then Laurent's tail solution will work. Except it will never finish and that may hang your script.
I suppose what you could do is exit when you see the End:
tail +1 -f abclog | awk '
/Start of x1 job/,/End of c2 job/ {
print $0
if ($0 ~ /End of c2 job/)
exit 0
}' | your-script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2012 06:23 AM
11-12-2012 06:23 AM