I start a bash script (synchronously from java as glassfish user) which triggers another bash script:
Script 1 executed from java:
#!/bin/bash
#Start script2 as myUser on myUser desktop
echo myPassword | su -c "export DISPLAY=:0.0;xhost +localhost;script2.sh;" myUser &
echo "After subscript"
#---------------
#... other tasks
#---------------
echo "Before exit"
exit 0
Script 2 executed from script 1
#!/bin/bash
# Start java app with date added by awk at the beginning of every line
java -cp .:./lib/* com.mypackage.MyClass 2>&1 | awk '{print strftime("%D %T",systime())" "$0 }' >> logFile.log &
# Start java app without date added by awk on logs
#java -cp .:./lib/* com.mypackage.MyClass 2>&1 >> logFile.log &
My problem is that the script 1 never exits unless I kill the java process started in the script 2. This problem DOES NOT occurs if I remove the awk part in the script 2 (if I use the commented java command line).
I'm running : - GNU bash, version 4.2.53(1)-release (x86_64-redhat-linux-gnu) on Centos 6.4 - java 1.6.45 X86_64 and Glassfish 3.1.2.2
&
from end ofawk
command – gwillie Aug 6 at 8:02java -cp .:./lib/* com.mypackage.MyClass 2>&1 | awk '{print strftime("%D %T",systime())" "$0 }' >> logFile.log
but it still hangs. – Qumo Aug 6 at 8:55var="$(java -cp .:./lib/* com.mypackage.MyClass 2>&1)"
for script 2 exit? – BinaryZebra Aug 6 at 14:59var="$(java -version)"
makes it exit? – BinaryZebra Aug 6 at 18:52var="$(java -version)"
makes it exit. But I thinks it is not representative because my java program never exists. – Qumo Aug 7 at 6:25