move runCmd into shared code