QP->start("/bin/sh", { "-c", "echo q | sudo -S hcitool info " + _ " addr" })
I'm not sure what the underscore is doing in there. Maybe a typo?
Why on earth would you think that
addr
inside a quoted string would refer to a program variable? If you had a variable
info
or
echo
in your program, would you expect the values of those to be substituted into the string as well????
Assuming std::string semantics for the arguments are for QP->start, then you should be able to use
QP->start("/bin/sh", { "-c", "echo q | sudo -S hcitool info " + addr });
If you the arguments are C style NUL terminated strings, then you've got options:
std::string cmdstr{"echo q | sudo -S hcitool info ");
cmdstr.append(addr);
QP->start("/bin/sh", { "-c", cmdstr.c_str() };
#include <cstdio>
char cmdstr[256]; sprintf(cmdstr, "echo q | sudo -S hcitool info %s", addr);
QP->start("/bin/sh", { "-c", cmdstr};
#include <cstring>
char cmdstr[256]{"echo q | sudo -S hcitool info "};
strcat(cmdstr, addr);
QP->start("/bin/sh", { "-c", cmdstr};
#include <sstream>
std::stringstream command{"echo q | sudo -S hcitool info "};
comand << addr;
QP->start("/bin/sh", { "-c", command.str().c_str() };
There's probably others as well. I'm sure QString and friends provide similar facilities.