Hi All,
I'm doing a script called script1, that run a external bin called process1. If process1 ends with a particular message I need to re-run process1 with a new parameter.
I do this and it worked but now I have to launch script1 from another called script2.
Script2 has to kill script1 after a timeout by a SIGTERM, I have the problem that process1 doesn't die.
I can't change Script2, I can only modify script1.
This is my code
script1
Code:
#!/bin/bash
ABSPATH=`readlink $0` #resolves symbolic link, if any
if [ -z "$ABSPATH" ]; then ABSPATH=$0; fi
ABSPATH=$(cd `dirname $ABSPATH` && pwd) #resolves relative paths
PROCESS1_HOME=$ABSPATH
echo $PROCESS1_HOME
export LIB_PATH=$PROCESS1_HOME/lib
CMD_LINE="$PROCESS1_HOME/process1"
TMP_OUT=/tmp/tmp_out
CMD_LINE="$CMD_LINE $@"
$CMD_LINE |tee $TMP_OUT
check=`cat $TMP_OUT | grep "rerun it" | wc -l`
if [ "$check" -eq 1 ]; then
CMD_LINE="$CMD_LINE -new_param"
$CMD_LINE |tee $TMP_OUT
fi
#cat $TMP_OUT
rm $TMP_OUT
exit 0
Thanks!