I have a problem with a script I wrote to install a bunch of apps, basically as it loops through an array of app names to install it checks them by doing:
dpkg -l | grep -q $i
and based on the $? will either install or skip the app. Trouble is for a few items it fails due to a dpkg lock, almost the whole list works, just half a dozen fail but work if you run the script again.
Is it possible to wait for dpkg to finish before running the 'apt-get install'?
For now I've added a 'sleep 0.5' between the 2 lines and this has stopped the problem but is obviously ugly and slower.
Thanks, Noki