Relevance statment in shell script

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