diff --git a/scripts/get_curr_exp b/scripts/get_curr_exp index da2ceeb9..ec601bb8 100755 --- a/scripts/get_curr_exp +++ b/scripts/get_curr_exp @@ -32,9 +32,8 @@ do esac done -DIRTMP=`dirname "${BASH_SOURCE[0]}"` -DIR="$( cd $DIRTMP && pwd -P )" -PATH=$PATH:$DIR +DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") +PATH=$DIR:$PATH if [ $INSTRUMENT != 'xxx' ]; then CURR_EXP=`get_info --hutch ${INSTRUMENT^^} --exp` diff --git a/scripts/get_hutch_name b/scripts/get_hutch_name index 84a6fa9e..9d15a20b 100755 --- a/scripts/get_hutch_name +++ b/scripts/get_hutch_name @@ -13,9 +13,8 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then exit 0 fi -DIRTMP=`dirname "${BASH_SOURCE[0]}"` -DIR="$( cd $DIRTMP && pwd -P )" -PATH=$PATH:$DIR +DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") +PATH=$DIR:$PATH hutch=`get_info --gethutch` echo $hutch diff --git a/scripts/get_lastRun b/scripts/get_lastRun index a7442f75..974a8bc0 100755 --- a/scripts/get_lastRun +++ b/scripts/get_lastRun @@ -19,9 +19,8 @@ AskLive=0 Ended=0 INSTRUMENT='xxx' -DIRTMP=`dirname "${BASH_SOURCE[0]}"` -DIR="$( cd $DIRTMP && pwd -P )" -PATH=$PATH:$DIR +DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") +PATH=$DIR:$PATH while getopts "H:i:le" OPTION do diff --git a/scripts/imgr b/scripts/imgr index aaf6d0fd..4af0c347 100755 --- a/scripts/imgr +++ b/scripts/imgr @@ -32,7 +32,7 @@ fi # Add engineering_tools to PATH for get_hutch_name DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") -PATH=$PATH:$DIR +PATH=$DIR:$PATH # Search for hutch in args for (( i=1; i<=$#; i++)); do diff --git a/scripts/iocmanager b/scripts/iocmanager index fd8eaf82..a25053ee 100755 --- a/scripts/iocmanager +++ b/scripts/iocmanager @@ -17,7 +17,7 @@ fi # Check hutch DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") -PATH=$PATH:$DIR +PATH=$DIR:$PATH HUTCH=${1:-$(get_hutch_name)} # Exit if hutch is still unknown diff --git a/scripts/ioctool b/scripts/ioctool index d5f8b91b..c6de2c34 100755 --- a/scripts/ioctool +++ b/scripts/ioctool @@ -9,19 +9,21 @@ function iocfpv { fi } -function iocdir { - ioc=$1 - iocpath="" - iocpath=$(grep_ioc "$ioc" all | grep "id:'$ioc'" | sed -n "s/^.*dir: '\(\S*\)'.*$/\1/p"); - if [[ -z $iocpath ]]; then - echo "Did not find ${ioc} running anywhere. Exiting..." >&2 +function iocinfo { + INFO="" + INFO=$(grep_ioc "$1" all | grep "id:'$NAME'") + if [ -z "$INFO" ]; then + echo "$1 could not be found. Exiting..." >&2 exit 1 fi - +} + +function iocdir { + iocinfo "$1" + iocpath=$(echo $INFO | sed -n "s/^.*dir: '\(\S*\)'.*$/\1/p"); if [[ ! $iocpath =~ ^/.* ]]; then - iocpath=/reg/g/pcds/epics/"${iocpath}" + iocpath=/reg/g/pcds/epics/"${iocpath}" fi - } function ioccfg { @@ -34,7 +36,6 @@ function ioccfg { exit 1 fi fi - } usage(){ @@ -121,15 +122,23 @@ elif [ "$CMD" == "data" ]; then ################################################################# elif [ "$CMD" == "telnet" ]; then - INFO=$(grep_ioc "$NAME" all | grep "id:'$NAME'") - if [ -z "$INFO" ]; then - echo "$NAME could not be found. Exiting..." >&2 - exit 1 - fi + iocinfo "$NAME" HOST=$(echo "$INFO" | sed -n "s/^.*host: '\(\S*\)'.*$/\1/p") PORT=$(echo "$INFO" | sed -n "s/^.*port: \(\S*\),.*$/\1/p") #if [[ 39000 >= "$PORT" >=39999 ]]; # echo "Host no in subnet that connect" echo "$HOST":"$PORT" telnet "$HOST" "$PORT" + +################################################################# + +elif [ "$CMD" == "host" ]; then + iocinfo "$NAME" + echo "$INFO" | sed -n "s/^.*host: '\(\S*\)'.*$/\1/p" + +################################################################# + +else + echo "Command not supported: $CMD" >&2 + exit 1 fi diff --git a/scripts/makepeds b/scripts/makepeds index 3cc8891c..e4e621f5 100755 --- a/scripts/makepeds +++ b/scripts/makepeds @@ -1,8 +1,7 @@ #! /bin/bash -DIRTMP=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") -DIR="$( cd $DIRTMP && pwd -P )" -PATH=$PATH:$DIR +DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") +PATH=$DIR:$PATH usage() { diff --git a/scripts/serverStat b/scripts/serverStat index fd989040..f28f11ff 100755 --- a/scripts/serverStat +++ b/scripts/serverStat @@ -53,21 +53,24 @@ isCam(){ host_from_PV(){ if [[ $NAME == *':'* ]] && [[ $HUTCH == 'unknown_hutch' ]]; then echo 'Getting info for a host of a PV currently only works on the hutch networks' - exit + exit 1 fi if [[ ${NAME:0:3} == "${HUTCH^^}" ]]; then HOST=$(cainfo "$NAME" | grep Host | awk '{print $2}' | awk 'BEGIN { FS = ":"}; {print $1}' | sed s/'.pcdsn'/''/g) if [[ $HOST == *'disconnected'* ]]; then - echo PV "$NAME" is disconnected - exit + echo "PV $NAME is disconnected" + exit 1 fi - echo PV "$NAME" is hosted on server "$HOST" - NAME=$HOST - DEV=$HOST else - echo 'Getting info for a host of a PV currently only works on the hutch network (e.g. for MFX:xxx from the mfx network)' - exit + HOST=$(ioctool $NAME host) + if [[ -z "$HOST" ]]; then + echo "Host can't be found for PV $NAME" + exit 1 + fi fi + echo PV "$NAME" is hosted on server "$HOST" + NAME=$HOST + DEV=$HOST } usage(){ @@ -88,9 +91,8 @@ expert : display info and run checks on server EOF } -DIRTMP=$(dirname "${BASH_SOURCE[0]}") -DIR=$( cd "$DIRTMP" && pwd -P ) -PATH=$PATH:$DIR +DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") +PATH=$DIR:$PATH HUTCH=$(get_hutch_name) for name in "tmo" "rix" "txi" "xpp" "xcs" "mfx" "cxi" "mec" "det"; do