A user-defined interactive shell program that can create and manage new processes.
C-Shell supports the following features :
- A prompt that displays username, systemname and current working directory.
- Builtin Commands:
pwd
,cd
,echo
,ls
,pinfo
,history
,repeat
,jobs
,fg
,bg
,sig
,replay
. - All other System Commands (with and wihout arguments).
- Process management (executing foreground and background) processes.
- Input/Output Redirection
- Piping
- Signal Handling for signals like SIGCHLD, SIGINT and SIGTSTP.
In the source directory
- Run the make command.
- Run ./a.out to start the shell.
- Enter exit to exit the shell.
-
The directory from which the shell is invoked is the home directory of the shell, represented by
~
. -
C-Shell supports
;
separated list of commands. C-Shell also handles random multipletabs
andspaces
in the command. -
Prompt
For every next command a prompt of the format<username@systemname:curr_dir>
is printed.
-
Apart from basic functionality
cd
command supports multiple flags.
,..
,-
,~
. More than one command-line arguments are not allowed.cd
with no flags or arguments cd into home directory. -
echo
command displays the line of text/string that is passed as a command line argument. -
pwd
command prints the path of the current working directory. -
ls
commands with multiple flags-a
,-l
, multiple directory/file names. Handles arguments in any order. -
pinfo
prints process related information.pinfo
accepts one command line argument that is PID and prints the process info of the givenPID
. With no command-line arguments, it prints the process info of theshell program
itself. Process info printed includes,pid
,process status
,virtual memory (in kB)
,executable path
.+
in process status signifies that the process is running inforeground
. -
repeat
command executes the given instruction multiple times. Format of the command will berepeat n instruction
, where n is a positive integer specifying the number of timesinstruction
should be repeated.Limitation
-repeat
does not work withbackground
processes. -
history
command prints the last10
commands executed by the shell across all sessions.history
accepts a positive integer (sayn)
as a command line argument and prints the last n commands executed by the shell across all sessions. Atmax
, the shell stores20
commands in history. -
jobs
command prints a list of all currently running background processes spawned by the shell, along with their job number, process ID and state, which can either beRunning
orStopped
. It also supports flags-r
and-s
for printing only running or stopped processes respectively. -
sig
command takes two command-line arguments, the first is thejob number
and second is thesignal number
. It sends the signal corresponding to signal number to that process specified by the job number. -
fg
takesjob number
as a command line argument and brings the running or stopped background job corresponding tojob number
to the foreground, and changes its state to running
. If no job with the given job number exists, it throws an error. -
bg
takesjob number
as a command line argument and changes the state of the background job corresponding to thejob number
fromstopped
torunning
(in the background). If the process was already running in the background, it has no effects. -
replay
command takes 3 command line arguments,command
,interval
andperiod
. It executescommand
in a fixedinterval
of time for a certainperiod
.
Other than the builtin commands, C-Shell executes all other system commands either in foreground or background. It supports the &
operator which lets a program run in the background after printing the pid
of the newly created process. Running a process in background implies that the shell will spawn that process and doesn't wait for the process to exit. It will keep taking other user commands. SeaShell can handle multiple background processes at a time. This implies that your shell will spawn that process and doesn't wait for the process to exit. It will keep taking other user commands. When the background process exits the shell, it display the appropriate message to the user.
Using the symbols <
, >
and >>
, the output of commands can be redirected to a file other than stdout, or the input taken from a file other than stdin. Input and output redirection can be used simultaneously. Error message is displayed if the input file does not exist. If the output file does not exist, it is created (with permissions 0644
).
Output file is overwritten in case of >
and appended to in case of >>
.
A pipe |
, redirects the output of the command on the left as input to the command on the right. Multiple
commands can piped.
Simultaneous I/O Redirection and Piping is also supported.
- Syntax for I/O redirection: < >
- Syntax for piping: | | .... |
- Syntax for Both implemented together: < | | ... | >
Ctrl C
- interrupts any currently running foreground job, by sending it the SIGINT
signal. It has no effect in case no foreground process is running on the shell.
Ctrl Z
(SIGTSTP
)- pushes any currently running foreground job into the background, and change its state from running to stopped.
If no foreground process is running on the shell, it has no effect.
Ctrl D
- logs you out of your shell, without having any effect on the actual terminal.
- Each command is no longer than 200 characters.
- There are no more than 200 background processes running at a time.
- In ls command, if the file is 6 months old, year is diplayed instead of time. Criterion for 6 months old: - If the year differ by 1 or more, then true. - If year is same and difference between present month and file's month is more than 6 then true. - If year is same and difference between present month and file's month is 6, if present day of month is more than file's day of month then true. - Rest all cases false.