#!/bin/bash # -*- sh -*- [ -z "$2" ] && echo "usage: $0 [ ...]" && exit 1 # Run something on a different host, keeping the current directory. # It's currently not clear if this is well-defined LOCAL_PATH=$(readlink -f .) case $(readlink -f .) in /net/*) NET_PATH=$LOCAL_PATH ;; *) NET_PATH=/i/$HOSTNAME/$LOCAL_PATH ;; esac HOST="$1" shift exec ssh "$HOST" "cd $NET_PATH ; exec $@"