Starting from:
$26.99

$20.99

Lab 10. Write your own UNIX Shell, part 2 Solution

Student will work with process management and some basic system calls.
Important note: please use sp1, sp2, sp3, or atoz servers for this lab.
UNIX Shell
In Lab9 we did the 3 built-in commands: cd, pwd, exit.l
Now we need to add an exec and code to handle redirection.
FILES TO COPY:
To get the file you need, first move to your class folder by typing: cd csc60
The following command will create a directory named lab10 and put all the needed files into it below
your csc60 directory.
Type: cp -R /gaia/home/faculty/bielr/classfiles_csc60/lab10 .
Spaces needed: (1) After the cp ↑ Don’t miss the space & dot.
(2) After the -R
(3) After the directory name at the end & before the dot.
After the files are in your account and you are still in csc60, you need to type: chmod 755 lab10
This will give permissions to the directory.
Still in csc60, type: cp lab9/lab9.c lab10/lab10.c
We have copied lab9 code and renamed it to lab10.c for you to start work on it.
Next move into lab10 directory and type: chmod 644 *
This will set permissions on the files.
Your new lab10 directory should now contain: lab10.c, waitpid.c, redir.c
A lot of code to be used in Lab10 is currently commented out.
Use the file Lab9-10 GuideToRemoveComments (on SacCT) to guide you to remove a set of the extra
comments.
Pseudo Code (Yellow highlight indicates the code from Lab9.)
/*----------------------------------------------------------*/
int main (void)
{
while (TRUE)
{
int childPid;
char *cmdLine;
print the prompt(); /* i.e. csc60mshell , Use printf*/
fgets(cmdline, MAXLINE, stdin);
Call the function parseline, sending in cmdline & argv, getting back argc
/* code to print out the argc and the agrv list to make sure it all came in. */
/* This code is not required for lab10. You may leave it in or get rid of it near the end. */
Print a line. Ex: “Argc = %i”
loop starting at zero, thru less than agrc, increment by one.
print each argv[loop counter]
 more on next page

More products