#!/bin/bash [[ -z $USER ]] && echo \$USER not defined && exit 1 [[ -z $1 ]] && echo port? && exit 1 [[ -z $2 ]] && echo remotesrv? && exit 1 port=$1 remotesrv=$2 tmp=`ps aux | grep ^$USER | grep 'ssh -fN -D'` [[ -z $tmp ]] && echo RESTARTING SOCKS && \ ssh -fN -D *:$port $remotesrv & #su - USERNAME -c "sleep 10; ssh -fN -D *:$port $remotesrv" & unset tmp