| | |
My own shell-wannabe
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 13
Reputation:
Solved Threads: 0
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:
but, I'm not really sure how is this suppose to look like :/
Could some1 help me out?
Shell Scripting Syntax (Toggle Plain Text)
#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?
![]() |
Similar Threads
- What exactly is Fedora? (Getting Started and Choosing a Distro)
Other Threads in the Shell Scripting Forum
- Previous Thread: How to generate a temp file until finish selected then replace to another file.
- Next Thread: opening multiples files in awk?
Views: 468 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting





