Powered by Invision Power Board


  Reply to this topicStart new topicStart Poll

> small programing help, user inputs parameters- modify my prog
naifq2
  Posted: Dec 17 2004, 04:48 PM
Quote Post


Newbie
*

Group: Members
Posts: 1
Member No.: 722
Joined: 17-December 04



hi and good morning

i have a program that i wrote for unix shels and i want to modify it so it have more functionability only.

i need this program to ask the user to INPUT any 2 arguments he wants and then it executes this arguments, the program should use pipes.

here is my program that it should be modified, if it cannot be modified or difficult please help me to create a new program to do the same functions.


int main(void)
{
int pfd[2];
int pid;

if (pipe(pfd) == -1)
{
perror("pipe failed");
exit(1);
}
if ((pid = fork()) < 0)
{
perror("fork failed");
exit(2);
}
if (pid == 0)
{
close(pfd[1]);
dup2(pfd[0], 0);
close(pfd[0]);
execlp("wc", "wc",
(char *) 0);
perror("wc failed");
exit(3);
} else {
close(pfd[0]);
dup2(pfd[1], 1);
close(pfd[1]);
execlp("ls", "ls",
(char *) 0);
perror("ls failed");
exit(4);
}
exit(0);
}
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Programming/Languages | Next Newest »

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.0719 ]   [ 12 queries used ]   [ GZIP Enabled ]




Partners: Cambridge Plus :: <Link Available> :: PIC Boot-loader Utility :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum