The attached snippet processes hcitool scan, with options and REDIRECT the standard output to BOTH screen / console ( Eclipse IDE term ) and system file (temp_file.txt ).
1. Why is it necessary to add 2 into redirection ?
Why not ">@1" ?
2. Without the "pipe | " hcitool complains about "too many parameters".
But wants / suggests "zero parameters "(?)
3. position of "tee" is also critical , AFTER the "|" and before the file.
4. When no output to console is needed , this works just fine
system("hcitool scan --info --class > temp_file.txt ");
system("hcitool scan --info --class 2>&1 | tee temp_file.txt ");
What I have tried:
Removing "2"
Removing "|"
Moving tee around.
Basically I need better / some explanations so blind "hit and miss"
coding is avoided.
Appreciate any on the subject comments.