From 9f28625f1a9b0de3282eccdc79e975b9c88704a3 Mon Sep 17 00:00:00 2001 From: Samantha Boyer Date: Thu, 27 Oct 2022 19:17:35 -0500 Subject: [PATCH] Committing again because push did not go through --- src/Integrated.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/Integrated.c b/src/Integrated.c index d578754..339c314 100755 --- a/src/Integrated.c +++ b/src/Integrated.c @@ -89,3 +89,65 @@ void ReadPishrc(CommandStruct* command, char* inputString) } assert(close(fd) >= 0); } +// i/o redirection +void ioRedirection(char* inputString, CommandStruct* command) +{ + int newfd; + // check command standard output +if (strchr(inputString, '>' )!= NULL) + { + + newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) <0) { + //failed + perror(command); + exit(1); + } + + // copies the new file descriptor + dup2(newfd,1); + }//this is supposed to close if statement?? + +// check command standard input + if(strchr(inputString, '<') != NULL) + { + newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) <0) { + //failed + perror(command); + exit(1); + } + dup2(newfd,0); + } + +//check pipe + if(strchr(command, '|') != NULL) + { + + } +//check append + if (strpbrk(command, ">>") != NULL) + newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) <0) { + //failed + perror(command); + exit(1); + } + dup2(newfd,0); + } + +//check pipe + if(strchr(command, '|') != NULL) + { + + } +//check append + if (strpbrk(command, ">>") != NULL) + { + + } +} +//Environment varibles +void varibles(char str, int count) +{ + char var[1000]; + var[count]= str; + +}