Red Squirrel
No Lifer
Is there a way I can perform a linux command within C++, then get the output of that command? I'm looking for something like system() but that I get the actual screen output. It would also be nice if I can send data back to the same "session"
So something like this:
Is this something that is easily doable? I *could* write a function that uses system, then redirects output to a temp file, then reads that file, but I'm wondering if there's something already built in that I can use. Bonus if there's a flag that can tell me if it's STDOUT or STDERR but that's not a requirement in my case.
So something like this:
Code:
string output = LinuxCommand("passwd user");
if(output == "Changing new password for user testuser.")
{
LinuxCommand("newpass");
LinuxCommand("newpass");
}
else cout<<"Invalid user";
Is this something that is easily doable? I *could* write a function that uses system, then redirects output to a temp file, then reads that file, but I'm wondering if there's something already built in that I can use. Bonus if there's a flag that can tell me if it's STDOUT or STDERR but that's not a requirement in my case.