I'm trying to call popen() using mingw like this:
#define RUN_COMMAND "\"C:\\Program Files\\CA\\BrightStor ARCserve Backup\\ca_qmgr.exe\" \"-list\""
int main() {
outputPointer = popen(RUN_COMMAND, "r");
...
}
But I can't get it working. I think it's a quoting nightmare ...
It turns out the popen function strips the quotation marks around the whole thing, eg. "C:/Program Files"
becomes C:/Program Files
and "Ab cd.exe" "ef gh"
becomes ab cd" "ef gh
. You can get around this by just adding quotation marks around the whole thing, eg. ""ab cd.exe" "ef gh""
which becomes "ab cd.exe" "ef gh"
as intended.
This solution was inspired by reply from Kaz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With