![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics 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 05:19 PM |
| Compile a code for running on boot | d4n1l0d | Filesystems, Disks and Memory | 2 | 08-14-2006 02:44 PM |
| How can i check my code .. | Dastard | Shell Programming and Scripting | 5 | 08-10-2006 01:26 AM |
| How to check for specific process running through shell | agp | Shell Programming and Scripting | 3 | 03-25-2006 06:24 AM |
| Perl running C code | gdboling | Shell Programming and Scripting | 1 | 09-02-2003 06:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate 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); } } |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|