anneranch
May 27th, 2019, 04:38 PM
I am seeking help in figuring out how to use “system” calls from within C++ code.
My goal is to utilize Linux “command” bluetoothctl.
It is my understanding bluetoothctl is based on “bluez” package and it is now part of the Linux kernel.
I have successfully implemented simple system call to test retrieve “bluetoothctl help “.
system("bluetoothctl help | tee /tmp/A_test_file.txt >&2");
Works as expected.
I am having issues replicating the following output from “terminal”:
j
im@jim-desktop:~$ bluetoothctl
Agent registered
#
Here is my first attempt to run similar code from C++
cout << "bluetoothctl " << [B]endl; // just to see the prompt
system("bluetoothctl | tee /tmp/A_test_file.txt >&2" ); // expecting "Agent registered " and [bluetooth]# prompt on next line
The “output” from “"bluetoothctl"command is only
Agent registered
both in A_test_file.txt and stdout as expected , but no [bluetooth]# prompt
This call is different from the bluetoothctl help” - it actually receives response from the “bluetoothctl” and then a prompt.
I would guess the system call “return” needs to be more than the actual first line output.
Perhaps “file descriptor” ?
I do not know how to modify the system call to be more useful / interactive.
Any help would be appreciated.
My goal is to utilize Linux “command” bluetoothctl.
It is my understanding bluetoothctl is based on “bluez” package and it is now part of the Linux kernel.
I have successfully implemented simple system call to test retrieve “bluetoothctl help “.
system("bluetoothctl help | tee /tmp/A_test_file.txt >&2");
Works as expected.
I am having issues replicating the following output from “terminal”:
j
im@jim-desktop:~$ bluetoothctl
Agent registered
#
Here is my first attempt to run similar code from C++
cout << "bluetoothctl " << [B]endl; // just to see the prompt
system("bluetoothctl | tee /tmp/A_test_file.txt >&2" ); // expecting "Agent registered " and [bluetooth]# prompt on next line
The “output” from “"bluetoothctl"command is only
Agent registered
both in A_test_file.txt and stdout as expected , but no [bluetooth]# prompt
This call is different from the bluetoothctl help” - it actually receives response from the “bluetoothctl” and then a prompt.
I would guess the system call “return” needs to be more than the actual first line output.
Perhaps “file descriptor” ?
I do not know how to modify the system call to be more useful / interactive.
Any help would be appreciated.