On 9/11/20 4:11 PM, RM wrote:
> I have such problem:
>
> string exec_system(string command) {
> /* here command == "php
> /home/robert/dirtyphp_cpp/build/apps/../../src/_dirtyphp2.php
> /home/robert/rozgloszenia/application_edit_obfuscated/config/constants.php
> " */
> const char *cmd = command.c_str();
> /* here problem: cmd == "p" */
What are the values of command[1], command[2], and cmd[2], cmd[3]? (I
assume that command[0] == 'p' and cmd[1] == 0). It's weird that c_str
truncates the string in that way. Maybe 'command' contains a double byte
string...
> array<char, 128> buffer;
> string result = ""; // cmd's stdout
> unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
> if (!pipe) {
> throw runtime_error("popen() failed!");
> }
> while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
> result += buffer.data();
> }
> return result;
> }
>
> I don't understand why cmd == "p". Please help.
> I use g++ in Linux Mint (g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0).
--
Cholo Lennon
Bs.As.
ARG