write out command to a script instead of piping commands directly into a shell which is causing issues on osx