Sponsored Content
Full Discussion: helpp!
Top Forums Shell Programming and Scripting helpp! Post 68793 by Hallosss on Thursday 7th of April 2005 06:12:29 AM
Old 04-07-2005
helpp!

hello
i am new at the UNIX programin thing
and i have this assignment, which would look so easy for many of u
the shell must do the followin thing:

exec parameter < input > output
and another 1
exec parameter < input | exec2 parameter > output

the teacher started it wiz the followin codin:

int main(int argc,char **argv){
pid_t pid; int status,nc;
char *buf; char **args;
buf=(char *)malloc(1024);
while (1){
printf("myShell$");fflush(stdout);
nc=read(0,buf,1024); args=parse(buf);
buf[nc-1]=0;pid=fork();
if(pid==0){
execvp(args[0],args);
printf("execvp failed\n");
}
else {
wait(&status);free(args);
}}}

can any one plzz help me to continue it?
usin simple codin,plz
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Helpp!!

Hello How to Display the odd/even lines from a file..??? how to display the lines containing a string &2 lines before & 2 lines after..??? Thanksss (3 Replies)
Discussion started by: Reham$
3 Replies

2. Red Hat

Fedora 20 new user and having critical situation !!! Helpp!!!

Hey guys..... Im new user for linux fedora 20.... i really need help ....... i have no idea why suddently when i turn on my laptop fedora turn to be black screen and ask me loging in , when i loging then nothing happen , it stay at the same screen... then i try to go to "with linux secure...,"... (2 Replies)
Discussion started by: asianfootball
2 Replies
Ns_Exec(3aolserver)					   AOLserver Library Procedures 				       Ns_Exec(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
Ns_ExecArgblk, Ns_ExecArgv, Ns_ExecProc, Ns_ExecProcess, Ns_Fork, Ns_GetEnviron, Ns_WaitForProcess, Ns_WaitProcess, ns_fork - External process execution SYNOPSIS
#include "ns.h" int Ns_ExecArgblk(char *exec, char *dir, int fdin, int fdout, char *args, Ns_Set *env) int Ns_ExecArgv(char *exec, char *dir, int fdin, int fdout, char **argv, Ns_Set *env) int Ns_ExecProc(char *exec, char **argv) int Ns_ExecProcess(char *exec, char *dir, int fdin, int fdout, char *args, Ns_Set *env) int Ns_Fork(void) char **Ns_GetEnviron(void) int Ns_WaitForProcess(int pid, int *statusPtr) int Ns_WaitProcess(int pid) int ns_fork(void) _________________________________________________________________ DESCRIPTION
These functions handle fork and exec operations. See files: nsd/exec.c, nsd/tclenv.c and nsthread/fork.c. Ns_ExecArgblk(exec, dir, fdin, fdout, args, env) Executes a command in a child process. Return process id of child process exec'ing the command or -1 on failure. Provides extended error checking and error messages. Ns_ExecArgv(exec, dir, fdin, fdout, argv, env) Execute a command in a child process using fork(2) and execve(2), returns the process id of child process exec'ing the command or -1 on failure. The child sends an extended error message to the parent. Ns_ExecProc(exec, argv) Executes a command in a child process. Returns the process id of the child process exec'ing the command or -1 on failure. Simpli- fies call to Ns_ExecArgv. Ns_ExecProcess(exec, dir, fdin, fdout, args, env) Executes a command in a child process. Returns the process id of the child process exec'ing the command or -1 on failure. Calls Ns_ExecArgblk with same arguments. Ns_Fork() Posix style fork(), using fork1() on Solaris if needed. See fork(2) man page. Calls ns_fork. Ns_GetEnviron() Returns pointer to the environment vector. Ns_WaitForProcess(pid, statusPtr) Wait for child process. Returns NS_OK on success, or NS_ERROR on failure. *statusPtr is set to the exit code of the child process. Ns_WaitProcess(pid) Wait for child process. Calls Ns_WaitForProcess with NULL statusPtr. Returns NS_OK on success, or NS_ERROR on failure. ns_fork() Posix style fork(), using fork1() on Solaris if needed. SEE ALSO
nsd(1), info(n) KEYWORDS
AOLserver 4.0 Ns_Exec(3aolserver)
All times are GMT -4. The time now is 03:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy