Relevance statment in shell script

Can this relevenace statment be mix with shell/action script? I am not sure if that’s doable or not.

if exists process “httpd"
final_str=”“
http=ps -eaf|grep "sbin/httpd"|awk ' {print $8}'|grep -v grep|sort|uniq|xargs
if [ ! -z “$http” ]
then
for http_path in $http
do
vers=$http_path -version 2>&1|head -1|awk ' {print $3}'
final_str=”$http_path:$vers"","$final_str
done
echo $final_str|sed ‘s/,$//g’ > /tmp/bftask_httpd.log
fi

if exists process “java"
weblogic=ps -eaf|grep -iw java|grep -vi nolio|grep -i weblogic| grep -v grep|awk ' {print $8}'|sort|uniq|xargs
if [ ! -z “$weblogic” ]
then
for java_path in $weblogic
do
weblogic_jar=locate "/weblogic.jar"
if [ ! -z “$weblogic_jar” ]
then
weblogic_vers=$java_path -cp $weblogic_jar weblogic.version|sed '/^$/d'|head -1|awk ' {print $1$2"_"$3}'
final_str=”$java_path:$weblogic_vers"","$final_str
fi
vers=$java_path -version 2>&1 |head -1|awk ' {print $3}'|sed 's/"//g'
final_str="$java_path:$vers"","$final_str
done
echo $final_str|sed ‘s/,$//g’ > /tmp/bftask_java.log
fi

Assuming you wanted to run different shell scripts within an actionscript based on the existence of different processes, you could try something like the following (I’ve not tested this, but it should hopefully give you some insight into the approach):

if {exists process "httpd"}
	delete __appendfile
	delete runscript.sh

	appendfile final_str=”“
	appendfile http=ps -eaf|grep "sbin/httpd"|awk ' {print $8}'|grep -v grep|sort|uniq|xargs
	appendfile if [ ! -z “$http” ]
	appendfile then
	appendfile for http_path in $http
	appendfile do
	appendfile vers=$http_path -version 2>&1|head -1|awk ' {print $3}'
	appendfile final_str=”$http_path:$vers"","$final_str
	appendfile done
	appendfile echo $final_str|sed ‘s/,$//g’ > /tmp/bftask_httpd.log
	appendfile fi

	move __appendfile runscript.sh
	wait chmod 555 runscript.sh
	wait "{pathname of client folder of current site & "/runscript.sh"}"
endif

if {exists process "java"}
	delete __appendfile
	delete runscript.sh

	appendfile weblogic=ps -eaf|grep -iw java|grep -vi nolio|grep -i weblogic| grep -v grep|awk ' {print $8}'|sort|uniq|xargs
	appendfile if [ ! -z “$weblogic” ]
	appendfile then
	appendfile for java_path in $weblogic
	appendfile do
	appendfile weblogic_jar=locate "/weblogic.jar"
	appendfile if [ ! -z “$weblogic_jar” ]
	appendfile then
	appendfile weblogic_vers=$java_path -cp $weblogic_jar weblogic.version|sed '/^$/d'|head -1|awk ' {print $1$2"_"$3}'
	appendfile final_str=”$java_path:$weblogic_vers"","$final_str
	appendfile fi
	appendfile vers=$java_path -version 2>&1 |head -1|awk ' {print $3}'|sed 's/"//g'
	appendfile final_str="$java_path:$vers"","$final_str
	appendfile done
	appendfile echo $final_str|sed ‘s/,$//g’ > /tmp/bftask_java.log
	appendfile fi

	move __appendfile runscript.sh
	wait chmod 555 runscript.sh
	wait "{pathname of client folder of current site & "/runscript.sh"}"
endif
1 Like

thanks Aram. I used the “prefetch” instead of appendfile in the if/else block.