-1

次のことを行うシェルスクリプトがあります

  1. ユーザー(johnsmith)としてsudoを実行し、いくつかのことを実行します
  2. そのユーザーを終了し、URL のステータスを確認します
  3. status が 1 でない場合は、もう 1 つのサーバーに SSH で接続し、スクリプトを実行します。

しかし、私がそれを実行しているとき、内部の行'ENDBASH'はまったく実行されていません。

     #!/bin/ksh
     echo "Outside ENDBASH ${@##*/}"

    sudo -u johnssmith bash <<'ENDBASH'  

    echo "Inside ENDBASH ${@##*/}"

    #Obtaining the new version file
    for file in "${@##*/}"
     do
     if echo "$file" | grep -E "abc_cde_efg"; then
         echo "Version found: $file"
    else
           echo "Version not found"
    fi
    done        
    exit
ENDBASH

urlArray=('http://server:port/servicename1/services/servicename1?wsdl' 'http://server:port/servicename2/services/servicename2?wsdl')

status=0
    for url in "${urlArray[@]}"
     do
       result=`curl -s $url`

        if (echo $result | grep '<?xml' >/dev/null 2>&1); then
           service=$(echo $url | cut -d"/" -f4)
           echo "$service is Running"
      else
           service=$(echo $url | cut -d"/" -f4)
          echo "$service is not Running"
         status=1
        fi
     done    
if [ $status != 1 ] ; then
 ssh -t username@hostname /home/dev_was/test1.sh 
fi
4

1 に答える 1