I'm trying to run the command ls /home/aidan/Pictures/Wallpapers/*/*.{jpg,JPG,png,PNG}
to get a list of wallpapers, and it runs fine in the terminal, but when I run it from C++ it tells me ls: cannot access /home/aidan/Pictures/Wallpapers/*/*.{jpg,JPG,png,PNG}: No such file or directory
. Does anyone know what's up?
The command I used to run it:
std::string exec(std::string command) {
const char *cmd = command.c_str();
FILE* pipe = popen(cmd, "r");
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";
while(!feof(pipe)) {
if(fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe);
return result;
}