I'm trying to capture the log output of a piece of software running in server mode on localhost
in the bash script that triggers the communication with the server via nc
.
The server is started like this:
java -Xms4g -Xmx6g -jar target/Semafor-3.0-alpha-04.jar model-dir:../semafor_malt_model_20121129 port:4444
The communication from the bash script is:
cat file | nc localhost 4444 > ./output
This captures the STDERR
output as is the case with nc
nicely.
But I can see lots of log messages scrolling through in the terminal window where I started the server, and my question is how I can capture these messages in the bash script (and thus save them under a specific filename file.log, which would be different for each file sent)?
I've tried various suggestions, like capturing the output from the bash command in a variable
var=$(cat file | nc localhost 4444 > ./output)
or even trying to capture the terminal output with script
but without any success. I'm clearly out of my depth here, and any pointers would be gratefully received.