Hey, I wanted to write a script that would act as a shell, meaning: would display prompt, read from keyboard and run system commands. My guess would be to use fork() and exec() and strtok(), so I wrote this:
#all includes <bla.h>
main(int argc, char *argv){
int proces;
char *line;
char *cmd;
int my_exec;
pid_t pid;
while(1){
printf("serwerX:1% ");
gets(line);
cmd=strtok(line," ");
pid=fork();
if(pid==0){
my_exec=execl(cmd);
if(my_exec==-1){
printf("error");
}
exit(0);
}
else{
sleep(1);
printf("serwerX:2% ");
exit(0);
}
}
}
but, I'm not really sure how is this suppose to look like :/
Could some1 help me out?