runon (316B)
1 #!/bin/bash 2 3 # run command on $1, ssh'ing if necessary 4 5 MACHINE=$(echo "$1" | cut -d'.' -f1) 6 HOST=$(hostname | cut -d'.' -f1) 7 shift 8 # http://superuser.com/a/403369/77814 9 quoted_args="$(printf " %q" "$@")" 10 11 if [ $MACHINE = $HOST ] 12 then 13 exec $quoted_args 14 else 15 exec ssh -q -t $MACHINE zsh -ic \"$quoted_args\" 16 fi 17 18