Folks;
i have a tool to check on some files, this tool runs using command line. when we run the tool on any file, it suppose to give you the file information to see if the file was digested into the system.
for example: if i have a file called "test.gz", when i run the tool which called "chktool" i do it like this:
# /opt/dev/chktool -getstat /home/test.gz
i normally get results looks like this:
Type F
Path /home/test.gz
Handle F431B8828E6D04
Mode 0766
UID 60000
GID 65534
Size 11706980
NAME test.gz
STAT CHEK
UID B0514B7A-D20E
then when the file is digested, and i run the same tool i got this result below (note the STAT changed from CHEK to ONLN)
Type F
Path /home/test.gz
Handle F431B8828E6D04
Mode 0766
UID 60000
GID 65534
Size 11706980
NAME test.gz
STAT ONLN
UID B0514B7A-D20E
I'm looking to write a script to capture the time when starting to ingest the file then keep running the tool until the status changes from CHEK to ONLN, once it's ONLN then check the time so i can see how long it took for this file to go from CHEK to ONLN.
There are a few different ways to do this. Without having the tool to test some different options, I can't say which I think would work best. You could try running a wrapper that executes time and then loops until the status change. Another way could be to watch the file access or modify time. (depending on whether file is actually modified when processed) Just a couple of ideas.
Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".
The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!
In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.
So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.
(there are different 'time' commands [i.e. time, times, timex], so you'll want to setup the output you need. You could also use the date command and calculate the passed time.)
function time_loop()
{
while [[ $STAT != "ONLN" ]]
do
STAT=$(/opt/dev/chktool -getstat /home/test.gz | grep STAT | awk '{print $2}')
done
}
time $(time_loop)