![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to get source code of Unix commands? | jagdish.machhi@ | Linux | 4 | 08-10-2007 07:44 AM |
| need help with some commands please | mujtba | UNIX for Dummies Questions & Answers | 2 | 01-14-2005 10:49 AM |
| commands | kironpmullamkuz | Security | 2 | 06-27-2002 08:45 PM |
| commands | Special K | UNIX for Dummies Questions & Answers | 3 | 02-12-2002 10:27 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
code that reads commands from the standard i/p and executes the commands
Hello all,
i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e pwd is remaining the same. what changes should be made in it to let it change the directories too. Code:
#include <stdio.h>
#include <string.h>
#define MAXLINE 50
int main(void)
{
char buf[MAXLINE];
printf("%% ");
while (fgets(buf, MAXLINE, stdin) != NULL)
{
buf[strlen(buf) -1] = 0;
system(buf);
printf("%% ");
}
}
|
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
|