Как указывали другие, popen()
является наиболее стандартным способом. И поскольку ни один из ответов не предоставил пример с использованием этого метода, вот он:
#include <stdio.h>
#define BUFSIZE 128
int parse_output(void) {
char *cmd = "ls -l";
char buf[BUFSIZE];
FILE *fp;
if ((fp = popen(cmd, "r")) == NULL) {
printf("Error opening pipe!\n");
return -1;
}
while (fgets(buf, BUFSIZE, fp) != NULL) {
// Do whatever you want here...
printf("OUTPUT: %s", buf);
}
if(pclose(fp)) {
printf("Command not found or exited with error status\n");
return -1;
}
return 0;
}
Здесь запрос дыры:
SELECT idperson, name
FROM movie.people
WHERE idperson LIKE '23'
OR idperson LIKE '1'
OR idperson LIKE '24'
OR idperson LIKE '25'
OR idperson LIKE '26'
OR idperson LIKE '27'
OR idperson LIKE '28'
OR idperson LIKE '29'
ORDER BY FIND_IN_SET(idperson,'23,1,24,25,26,27,28,29');