#!/bin/bash SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink TARGET="$(readlink "$SOURCE")" if [[ $TARGET == /* ]]; then SOURCE="$TARGET" else DIR="$( dirname "$SOURCE" )" SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located fi done SRPATH="$( dirname "$SOURCE" )" SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" if [ "$SFPATH" != "$SRPATH" ]; then RDIR=$SRPATH # relativ path directory fi cwdir=$PWD wdir=$SFPATH if [[ $# -eq 0 ]] ; then echo 'no service' exit 1 fi if [[ -z "$1" ]] ; then echo 'no service' exit 1 fi if [[ -z "$2" ]] ; then echo 'no port' exit 1 fi R_PORT1=$2 service=$1 #string=$(tr -dc A-Za-z0-9