I am working on optimization, and for this I need to link the matlab code with the linux program and monitor the results. I made this link using this sh below, however this did not work since I could not track more than one expression.
#!/bin/bash
../program inputfile &> OutputFile.dat &
tail -f OutputFile.dat | sed -n '/NaN/q;/STOP/q'
killall program
I asked for help here and I got a good solution. The solution partially solved the problem. By running the program at the prompt, you could track these expressions and kill the program when necessary. The solution is given:
#!/bin/bash
( stdbuf -o 0 -e 0 ../program inputfile & ) &> OutputFile.dat
sed -n '/NaN/q;/STOP/q' <(tail -f OutputFile.dat)
killall program
When I implemented on Matlab and did the "binding", the code did not respond well. After several minutes of work, Matlab was stuck, I could not get any response from the terminal. When I looked at the outputs of my program manually, I realized that there are no problems in the program, and the outputs are usually recorded.
I can not solve this problem. I do not have much experience working on sh. I was looking for answers, but I could not find them. Alternative suggestions to achieve the same are also welcome.
Thanks in advance
source
share