This nifty little script was suggested by Michael Pauli, one of our customers. It will start Sauce Connect, then run your tests and close Sauce Connect afterwards. It relies on Bash and is designed to wrap around Maven. You could replace 'mvn clean test' with your own test framework's command and experiment with the results.
vendor/sauce-connect/bin/sc -u your_username -k your_access_key --pidfile pid > /tmp/sauce-connect-log.txt & sleep 1 while ! grep -m1 'Sauce Connect is up, you may start your tests.' < /tmp/sauce-connect-log.txt; do sleep 1 done echo Sauce-Connect is up and running mvn clean test …. kill $(cat pid)