Starting from:
$30

$24

Compiling and Linking Solution

•  Two files are provided – shell.I and argshell.c (argshell.c is the one that you need to work in)




•  Shell.I is a parser. To compile it, do:




% flex shell.I




•  Need to compile and link your code and parser together! % cc –o argshell argshell.c lex.yy.c -lfl




•  Argument after “-o” is the running program name. Now to run the program, do:




% ./argshell

Running the Program










•  $ ./argshell




Command ('exit' to quit): ls -l




Argument 0: ls




Argument 1: -l




total 140






-rwxr-xr-x 1 hcasalet wheel
25930 Jan
6 12:12 argshell
-rw-r--r-- 1 hcasalet wheel
2140 Jan 6 00:05 argshell.c
-rw-------
1 hcasalet wheel 4644864 Jan 5 23:51 argshell.core
-rwxr-xr-x 1 hcasalet wheel
25124 Jan
5 12:14 argshell.o
-rw-r--r-- 1 hcasalet wheel
45083 Jan 5 11:22 lex.yy.c
-rwxr-xr-x 1 hcasalet wheel
25025 Jan
5 11:31 lex.yy.o
-rw-r--r-- 1 hcasalet wheel
707 Jan 5
10:53 shell.l



Command ('exit' to quit): exit




Argument 0: exit




Exiting...




$

The Rubric










•  Code needs to be pushed to Git in order to get credit. Make sure that your code compiles!




•  First project is individual project, rest of them are done in groups of size two. A captain is selected for each group. Only captains push code to Git.




•  Captains need to give access to team members:




% ssh git@git.soe.ucsc.edu/..../captain_cruzid +WRITERS team_member_cruzid




•  Team members then git clone from their captains




git clone git@gitlab.soe.ucsc.edu:cmps111/fall18-01/[CRUZID].git
The Rubric (continued)









•  Git commands review




•  git add, git commit, git push




•  Need to write:

•  A design doc – How you design your shell

•  A readme file – To let users of your shell to know how to use it

•  A make file – an OS tool to help simplify building running program. Example:




build an executable named myprog from myprog.c all: myshell.c
(tab) cc -o myshell myshell.c clean:

(tab) $(RM) myshell




Make sure that your Makefile works!



•  All the above, along with your code, need to be pushed into Git.




Unix Shell in FreeBSD










•  Shell - User interface to gain accesses to the services provided by the Operating System




•  Could be Command Line Interface, or Graphic User Interface •  Shell interprets user commands, and makes system calls. •  Shells in FreeBSD

•  Tcsh - Default shell




•  Bourne shell available to install (pkg install bash)

System Calls










•  What is a system call? – A way for programs to communicate with the Operating System.




•  When to make a system call? – when programs request services from the kernel.




•  Types of system calls:




•  Process management

•  Memory allocation and management




•  File access

•  Device manipulation

•  Protection

•  Communication




•  And more

System calls (continued)










•  Process Management - fork(), wait(), exit(), execvp()




•  File Access – open(), close(), dup(), dup2()




•  Communication – pipe()




•  Directory Management – chdir(), getcwd()

More products