|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | 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 !! |
![]() |
|
|
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); } } |
| Sponsored Links | ||
|
|
|
|||
|
It worked for me with a slight change.
system("ls"); BTW: Please post C related questions in "C Programming in the UNIX Environment" section. Thanks. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
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 03:44 PM |
| How can i check my code .. | Dastard | Shell Programming and Scripting | 5 | 08-10-2006 02: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 07:43 PM |