Advertisement
vartik

sshw.sh

Feb 18th, 2016
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/sh
  2. [ -z $1 ] && echo "Usage: $0 <ssh_host> [ssh_options]" && exit
  3. SSH_HOST=$1 # FIXME: Host may be defined anywhere
  4. [ "$1" == "-p" ] && SSH_PORT=$2 && SSH_HOST=$3 # FIXME: Port may be defined anywhere
  5. [ "$2" == "-p" ] && SSH_PORT=$3 && SSH_HOST=$1 # FIXME: Port may be defined anywhere
  6. [ -z $SSH_PORT ] && SSH_PORT=22
  7. until nc -w 1 $SSH_HOST $SSH_PORT < /dev/null | grep -i ssh ; do
  8.         sleep 1
  9. done
  10. ssh $*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement