From: Colin P. Mccabe Date: Tue, 29 Nov 2016 22:53:29 +0000 (-0800) Subject: dssh: add the ability to execute arbitrary commands X-Git-Url: http://www.club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=952f54e48416e47645cd277de86774525e74c40f;hp=444b95a4c8e1917ddde89c9288b189840d1fdb53;p=cmccabe-bin dssh: add the ability to execute arbitrary commands --- diff --git a/dssh b/dssh index a00ca4d..710fdac 100755 --- a/dssh +++ b/dssh @@ -35,6 +35,12 @@ while getopts "hi:n:" flag; do exit 1;; esac done +shift $(expr $OPTIND - 1) +if [ $# -eq 0 ]; then + RUN_COMMAND="/bin/bash" +else + RUN_COMMAND="${@}" +fi which docker &>/dev/null || die "docker must be on the PATH." @@ -55,4 +61,4 @@ else die "failed to find a docker image named ${DOCKER_IMAGE_NAME}" fi -docker exec -it "${DOCKER_IMAGE_ID}" /bin/bash +docker exec -it "${DOCKER_IMAGE_ID}" ${RUN_COMMAND}