![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to check if a process is running in a server from shell script. | debu | UNIX for Advanced & Expert Users | 2 | 01-24-2008 01:19 PM |
| Compile a code for running on boot | d4n1l0d | Filesystems, Disks and Memory | 2 | 08-14-2006 11:44 AM |
| How can i check my code .. | Dastard | Shell Programming and Scripting | 5 | 08-09-2006 10:26 PM |
| How to check for specific process running through shell | agp | Shell Programming and Scripting | 3 | 03-25-2006 02:24 AM |
| Perl running C code | gdboling | Shell Programming and Scripting | 1 | 09-02-2003 03:43 PM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi mates,
i am trying to run a shell command from my C program in this case let is say the "ls" command. It copiles it okay, and even creates the new fork too. But seems to nothing is happening i mean it is not showing the result of the "ls" command. I don't know wat i am doing wrong. Any comment will be appreciated. abdul #include <unistd.h> #include <sys/wait.h> #include <stdio.h> int p_id; int child_status; int cpid; main() { cpid=fork(); switch (cpid) { case -1: perror("fork"); exit(1); case 0: printf("The fork is successful!\n"); system('ls'); exit(0); default: wait(&child_status); } } |
| Forum Sponsor | ||
|
|