Generalize run-command function, add function for copying files