Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: mbertrand on March 07, 2013, 11:31:40 AM
-
At the end of the bootlocal.sh I'm starting my console app in the background
after that I'm calling "/bin/plymouth --quit" to shut down the splash screen. Is there a way to know after I start my app within a certain time out if my app has started. This would allow me to close the splash screen only when the app has started.
-
Hi mbertrand
Try:
ps | grep YourApplicationsName | grep -v grep
-
Thanks, but I'm kind of new to Linux. I would need to maybe loop until it has started for a max of x seconds before closing splash screen but I don't know how to loop in script file. I will Google!
-
Hi mbertrand
I think this might work:
#!/bin/sh
Timeout=10
until ps | grep YourApplicationsName | grep -v grep
do
sleep 1
let "Timeout -= 1"
[ $Timeout -le 0 ] && break
done
A brief explanation of what it does (or should do, did not test it):
The ps command returns a list of processes currently running. Once your app starts, it will be listed.
The first grep command searches for your apps name and the second grep command filters out results containing
the word grep, since running grep adds it to the list of processes.
The commands between do and done will execute until your app starts.
The variable Timeout is decrement by one each time through the loop. When it hits zero, you drop out of the loop.
You can test Timeout later in your script to determine if your app started or you just timed out.
-
Thanks
I'm a C++ software developer so it's a question of knowing the syntax and now I'm finding out that BuzyBox does not have full implementation of sh and it is 'ash" and not sh. Is this correct? Now I can't even find the right documentation!
I've tried your example and I'm getting:
sh: 0: unknown operand
and I'm in an infinite loop?
-
Hi mbertrand
There was a typo in the line with the break statement, corrected original post.
sh is a link in /bin that points to the default shell, which is busyboxs ash.
-
Thanks again.
-
Hi mbertrand
No problem. By the way, debugging a script is just like debugging any other program when no other tools are
available. Place a # sign on a line to comment it out to see if it's causing an error. Use echo to print out
variables to the screen.
-
Thanks