我有一个shell脚本来执行以下操作
但是当我运行它时,'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
答案 0 :(得分:0)
您需要将脚本收到的参数显式传递给内部脚本:
sudo -u johnssmith bash -s "$@" <<'ENDBASH'