Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do something for x Seconds

Status
Not open for further replies.

Taiger

Programmer
Nov 22, 2007
4
EU
Hello Again,

I got so good answer the last time I asked her that I think I try again :)
I’m trying to make a program that is searching text for 10 seconds and
Then print what it found from the stored arrays.

But I can’t seam to find any suitable command to use for timing

=====

Awk ‘ /sometext/ { array[n++]= "%s",$5
END {
while (n-->0) print array[n];
} '

=====

How to be able to run this for 10 seconds and then print all the
found arrays on last line and then start over?
 
Here's my suggestion. Put your 'searching program' into its own script, with the output written into a temporary file (instead of an array). Then from a 'wrapper script' call the 'searching program' and run it in 'background' (put '&' after the call), wait (sleep) for x Seconds, then read the results from the temporary file. The 'searching program' may continue to run for some time, so either let it run, or kill it.


I hope that helps, to get you started.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top