I would like to know how I can manipulate C program to run command in the terminal.
For example: If I run this statement PS1="Linuxrocks $", it runs fine in the terminal. But how would I write a program to do the the same thing. Or what function do I use?
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <unistd.h>
int main() {
char *argv[3] = {"Command-line", ".", NULL};
int pid = fork();
if ( pid == 0 ) {
execvp( PS1="linuxrocks $", argv );
}
wait( NULL );
printf( "Finished executing the parent process\n" );
return 0;
}