I want to redirect the time data into file,I use the child_process to execute shell script the code as follow:
var timeAspCommand = "{ time clingo" + " " +programParam + " " + dataParam +" 2> clingo_sterr ; } 2> /root/output/output_clingo.txt"
let timeAspChildProcess = exec(timeAspCommand, function ( error, stdout, stderr){
cb(null,stdout)
});
the output/stdout is :
clingo version 5.4.0
Reading from ...ngo/clingoProgram/borda_asp_program.lp ...
Solving...
Answer: 1
borda_win(2) borda_score(1,-286) borda_score(2,382) borda_score(3,88) borda_score(4,-292) borda_score(5,108)
SATISFIABLE
Models : 1
Calls : 1
Time : 0.002s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time : 0.002s
I expect the content of output_clingo.txt is :
real 0m0.005s
user 0m0.005s
sys 0m0.000s
after that, however, I imput the shell script :
cat/root/output/output_clingo.txt,there is nothing to show .
here is what I have tried :
I just input the command line:
{ time clingo /root/clingo/clingoProgram/borda_asp_program.lp /root/clingo/clingoProgram/borda_asp_dataform.txt 2> clingo_sterr ; } 2> /root/output/output_clingo.txt
then I check the content of the output_clingo.txt by
cat/root/output/output_clingo.txt
and I get :
real 0m0.005s
user 0m0.005s
sys 0m0.000s
this is just what I expect!!! however,when I use the child_process to execute the same shell script , I can't make the content into the output file.
what should I solve this problem?
thanx!