if [ $? -eq 0 ]; then echo "service $i started by script" else echo "service $i could not be started. Error: $error" fi