/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include <string.h>
#define LE_INFO(a, ...) printf((a), __VA_ARGS__)
int main()
{
FILE *fp;
char consoleOutput[256];
const char* cmdPtr = "/bin/uname -a";
fp = NULL;
memset(consoleOutput,0x00,sizeof(consoleOutput));
LE_INFO("Start cmd : %s\n",cmdPtr);
fp = popen(cmdPtr,"r");
if (NULL != fp) {
LE_INFO("Success cmd : %s\n",cmdPtr);
while (fgets(consoleOutput, sizeof(consoleOutput)-1, fp) != NULL) {
LE_INFO("Cmd Output : %s", consoleOutput);
}
}
else {
LE_INFO("Failed cmd : %s",cmdPtr);
}
return 0;
}