i want to run a shell script remotely via ssh and the ssh shell should end when the script ends. The script itself runs another script whose output is piped to a log file.
Example: I run the script run1.sh:
#!/bin/sh
function logpipe() {
while read line;do
echo $line >> $1
done
}
./bin/run2.sh $JBOSS_HOSTNAME | logpipe $JBOSS_DIST/log/server.log 2>&1 &
run2.sh:
#!/bin/sh
exec "$JAVA" -DJBOSS_PID=_$$_ $JAVA_OPTS \
-Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
-classpath "$JBOSS_CLASSPATH" \
org.jboss.Main "$@"
Now the problem is when i run
ssh myhost "bin/run1.sh"
the shell gets "stuck" to the script and i only can get it loose by closing it via Crtl+C. I guess the trick is something between nohup and another piping trick but i just couldn't get to it by now.