I would like to write the a startup script in bash to make an ubuntu box more grandpa-friendly.
The script should:
open chrome
wait until chrome is closed
turn computer off
so far I have
#!/bin/bash
if [ -z "$1" ]; then
address="http:\\www.google.co.uk"
else
address=$1
fi
echo starting the internet
google-chrome $address
while [ 1=1 ];
do
grep_resp=$(ps aux | grep chrome)
if [ -z "$grep_resp" ]; then
echo turning computer off
else
echo chrome still running
fi
sleep 5
done
but the grep for “chrome” is in the process list
Any aid?
You’re getting that error because
$grep_respin this……probably expands into a string containing whitespace. If you put quotes around it:
It will do what you expect. However, I think all of that may be unnecessary. Chrome doesn’t automatically background or anything when it runs, so you should be able to do this: