diff options
Diffstat (limited to 'xsh')
-rwxr-xr-x | xsh | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -3,7 +3,7 @@ SCRIPT=$(basename $0) usage() { - echo "Usage: $SCRIPT [--x] [--verbose] [[su] [{user}@]{host}] [-- command...]" + echo "Usage: $SCRIPT [--x] [--verbose] [[su|sudo] [{user}@]{host}] [-- command...]" } termwrapper() { @@ -26,6 +26,7 @@ termwrapper() { # Initial setup SU='' +SUDO='' X='' V='' HOST='' @@ -33,7 +34,8 @@ ssh_opts="-t" while [ $# -gt 0 ]; do case $1 in - su) SU=1;; + su) SU=1; SUDO=;; + sudo) SUDO=1; SU=;; --x|-x|x) X=1; ssh_opts="$ssh_opts -X";; --ssh2|-2) ssh_opts="$ssh_opts -2";; --verbose|-v) V=1; ssh_opts="$ssh_opts -v";; @@ -74,11 +76,14 @@ fi prg="$prg_base $prg_opts" prg_su="echo -n 'Changing to root...: '; su -c \"cd; $prg\"" +prg_sudo="sudo -i -- $prg" case "$HOST" in '') if [ -n "$SU" ]; then termwrapper $prg_su + elif [ -n "$SUDO" ]; then + termwrapper $prg_sudo else termwrapper $prg fi @@ -86,6 +91,8 @@ case "$HOST" in *) if [ -n "$SU" ]; then termwrapper ssh $ssh_opts $HOST $prg_su + elif [ -n "$SUDO" ]; then + termwrapper ssh $ssh_opts $HOST $prg_sudo else termwrapper ssh $ssh_opts $HOST $prg fi |