Index of /school/Computer Science/cs153/as1/
Name | Last Modified | Size |
---|---|---|
Parent Directory | ||
backup.cc | 2011-07-14 07:00 | 14k |
makefile | 2011-07-14 07:00 | 1k |
myshell | 2011-07-14 07:00 | 22k |
myshell.cc | 2011-07-14 07:00 | 13k |
myshell.o | 2011-07-14 07:00 | 10k |
Ryan Hoskin
XXX-01-3343
Computer Science 153
Assignment 1 - Basic Shell
My program is a basic shell that can run various command such as cd,
pwd, along with other executable programs that are on the system.
First, my program uses my shell class, fsh. Fsh contains various
functions that will take in the user input, parse that input, run the
specified command, and return some output. Along with this, a history
of the commands entered are stored in the fsh class, allowing the user
to execute past commands by !# notation or the past command by
executing the !! command.
How my program works specifically is to first take in the command,
then this command is checked to see if it is an internal command. If
the entered command is not an internal command, then the command is
passed to a parsing function that will parse the given input. While
the command is being parsed it checks for certain special characters
such as "&" or "|". If these characters are detected in the command
string then other functions will be called.
If the pipe character "|" is encountered, the mypipe function is
called, where the output of the first program is redirected and used
as the input for the second executable. After this is achieved each
program is executed. Within this execution the program is searched
for in the find function, and if it is found as an executable on the
system then it will be executed.
If one of the redirect operators are found, ">", ">>", or "<", the
redirect function is called, where the input or output of the
input/output stream is redirected to the specified source/output.
To view the history a user can type: "history"
To view the present working directory: "pwd"
To change a directory: "cd <dir>"
To exit: "exit"
To compile the executable type "make" in a shell, and the executable
created will be named "myshell".
Proudly Served by LiteSpeed Web Server at ryanhoskin.com Port 443