I am currently working on a ssh program and I want to be able to have full control over the terminal via networking. My question is, if I send a command to the server to run in
You want the "popen" function. Here's an example of running the command ls /etc
and outputting to the console.
#include#include int main( int argc, char *argv[] ) { FILE *fp; int status; char path[1035]; /* Open the command for reading. */ fp = popen("/bin/ls /etc/", "r"); if (fp == NULL) { printf("Failed to run command\n" ); exit; } /* Read the output a line at a time - output it. */ while (fgets(path, sizeof(path), fp) != NULL) { printf("%s", path); } /* close */ pclose(fp); return 0; }