PART I: To Develop a Bash Script
. echo lpstat sort at env ls spell export exit mail su bash man tail bc file mesg tee tail cal find mkdir touch cat grep mv umask cd finger passwd lp/lpr chmod id pwd vi history ps chown jobs rm wc clear kill rmdir who cp ln cp sleep write date
Type Commands
Simple: Status:
date, cal, finger, ls, cd, pwd
jobs, who, id, env, umask, mesg, history
File: Filters:
file, cp, mv, ln, rm, rmdir, mkdir, touch, chmod, tail
cat, sort, spell, grep, wc, tee
Misc: bc, mail, vi, lp, at, kill, find, passwd
CIS 345: Operating Systems Configuration & Use
Final Project
Guideline
#!/bin/bash
#
# menu: A simple Starter Template
#
while true
do
clear
echo -n "
CIS 345 Term Project
1) Objective 1
2) Objective 2
3) Objective 3
4) Objective 4
5) Objective 5
6) Exit
Your Choice>>>: "
read RESPONSE
case $RESPONSE in
1) # Commands for Objective 1
;;
2) # Commands for Objective 2
;;
3) # Commands for Objective 3
;;
4) # Commands for Objective 4
;;
5) # Commands for Objective 5
;;
6) exit 0
;;
*) echo "Enter a number in the range 1 – 6,
Please:"
;;
esac
echo -n "To return to the menu, hit the ENTER key "
read dummy
done
Information
Use vi or your editor of choice to code your script. Vi adds color to make your commands easier
to read.
Save versions of your script. You can do this using CVS or by copying script_gX to script_gX.v1,
script_gX.v2, etc. to backup each version.
What do I need to turn in?
Due Date:
Presentation: TBA
Rubric:
Possible Points Requirements
25 Implementing all five commands (5 points each):
• Requirements for each task: ‒Minimum of 10
script command lines ‒Has comments to explain
what it does ‒Has user interaction – covers
difficulty levels
20 You don’t have to do all of these but do at least 4 of them:
• Use of permissions (5 points)
• Use of absolute path (5 points) • Use of relative path (5 points)
• Use of a PID (5 points) • Use of inodes (5 points)
• Use of links (5 points) • Use of a GID or group (5 points)
• Use of a UID or user (5 points) • Use of a signal (5 points)
• Use of piping (5 points) • Use of an environment variable (5 points)
• Use of a comment (5 points)
• Use of /bin/mail (5 points) • Use of a conditional (5 points)
The maximum for this section are 20 points.
15
Log files for representing history
-60 Failure to present your work in the assigned day (all of the group members)
-40 Missing 3 requirement parts Points lost
-25 Fails to run by us (test it on different accounts)
-15 The other group users are unable to read and execute your script.
-5 For each error message displayed
-10 Missing readme file
-25 Not using functions for all tasks
-10 Missing documentation with screenshots
Extra credit 10 Up to four additional tasks (2.5 points each)
5
Fully functional log files representation for the
history utility. This works as if you are calling history with its parameters
5 Miscellaneous extra goodies
PART II: To create a man page via RCS
.\" This is a man page for the numusers command. It is intended to
.\" be a model for writing man pages.
.\" Written by .
.TH NUMUSERS 1 "03/27/2015" "(C) My ShellScript" "Mr. Ahmed"
.SH NAME
numusers \- Display the number of users currently logged in
.SH SYNOPSIS
.B numusers
[ \fB-v\fR ]
.SH DESCRIPTION
The
.B numusers
command simply displays the number of users currently logged in
to the computer.
The default output is a single number.
.PP
The command is just a "one liner" shell script.
.TP
.B -v
displays the output in a more verbose manner.
.SH AUTHOR
),
.SH SEE ALSO
who(1), wc(1)
Ahmed Abu Khalil, Ramtha Jordan, 12/2015
Mohammed AbuKhalil ([email protected]
-
-
-
-
[Nedal@JustWarrior Nedal]$ vi .bash_profile
[Nedal@JustWarrior Nedal]$ PATH=$PATH:~/bin
[Nedal@JustWarrior Nedal]$ mkdir bin
[Nedal@JustWarrior Nedal]$ cd bin
[Nedal@JustWarrior bin]$ vi numusers
[Nedal@JustWarrior bin]$ chmod u+x numusers
[Nedal@JustWarrior bin]$ numusers
There are 3 users on the system.
[Nedal@JustWarrior bin]$ mkdir RCS
[Nedal@JustWarrior bin]$ ci -r1.0 numusers
RCS/numusers,v <-- numusers
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> Script that displays the number of users logged on.
>> .
initial revision: 1.0
done
[Nedal@JustWarrior bin]$ co -l numusers
RCS/numusers,v --> numusers
revision 1.0 (locked)
done
[Nedal@JustWarrior bin]$ vi numusers
[Nedal@JustWarrior bin]$ numusers
3
[Nedal@JustWarrior bin]$ numusers -v
There are 3 users on the system.
[Nedal@JustWarrior bin]$ ci -u numusers
RCS/numusers,v <-- numusers
new revision: 1.1; previous revision: 1.0
enter log message, terminated with single '.' or end of file:
>> Added $Id$ comment, added "-v" argument for verbose output.
>> .
done
[Nedal@JustWarrior bin]$ rlog numusers
RCS file: RCS/numusers,v
Working file: numusers
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
Script that displays the number of users logged on.
----------------------------
revision 1.1
date: 2009/12/11 22:35:09; author: Nedal; state: Exp; lines: +7 -2
Added $Id$ comment, added "-v" argument for verbose output.
----------------------------
revision 1.0
date: 2008/04/11 22:32:29; author: Nedal; state: Exp;
Initial revision
=============================================================================
[Nedal@JustWarrior bin]$ rcsdiff -r1.0 numusers
===================================================================
RCS file: RCS/numusers,v
retrieving revision 1.0
diff -r1.0 numusers
2c2
<
---
> # $Id: numusers,v 1.1 2003/04/11 22:35:09 user Exp $
6c6,11
< echo There are $NUM users on the system.
---
> if test "$1" = "-v"
> then
> echo There are $NUM users on the system.
> else
> echo $NUM
> fi
[Nedal@JustWarrior bin]$ ls -l numusers
-r-xr--r-- 1 user user 206 Apr 11 18:35 numusers
[Nedal@JustWarrior bin]$ more numusers
#!/bin/bash
# $Id: numusers,v 1.1 2003/04/11 22:35:09 Nedal Exp $
# Written by Wayne Pollock
NUM=$(who | wc -l)
if test "$1" = "-v"
then
echo There are $NUM users on the system.
else
echo $NUM
fi
[Nedal@JustWarrior bin]$
Requirements:
2. :
$ to_do
1 Buy some bread
2 Clean your room
3 Do your homework
$
8.
$ to_do
1 Buy some bread
2 Do your homework
3 Clean your room
$ to_do Win the lottery
$ to_do
1 Buy some bread
2 Do your homework
3 Clean your room
4 Win the lottery
$
Deliverables:
Due Date: December
Presentation: TBA
Rubric:
Final Project Instructions:
Make sure to follow the instructions of submission, what to submit,
what to do for each part of the project.
The deadline is strictly as specified. Please do not leave
submission till the last minute! 1 minute late is considered as 1 hour,
and we will deduct 10% of the grade for every hour.
Do not make multiple submissions so you do not confuse us with which
version to grade and to avoid late submissions.
Start with part I first!
Possible Points Requirements
24 The final version of to_do.1,v RCS file
16 Answers to questions (do not forget that the questions are the walkthrough to most of how you
should do this part!)
-40 Failure to present your work in the assigned day (all of the group members)
-20 Missing 3 requirement parts Points lost
-15 Fails to run by us (test it on different accounts)
-5 For each error message displayed
-15 Missing documentation with screenshots
Extra credit
5 Fully functional with no errors including accessibility and going back and forth between
versions as described in the tutorial through menus.