For each of the following programs in Linux, give both the
user
and
others
permission to execute the files and
make sure they execute properly
. Copy the programs to a Word document, in order. The
comment(s)
in the program can simply describe what they do. (You don’t need one for every line.)
1. Type a commented script file named
lab13
in your home directory to do the following:
1. Clear the screen
2. Ask the user for their family name
3. Ask the user for their middle name
4. Ask the user for their hometown
5. Ask the user to type the number of the day on which they were born.
6. Print on the screen “You logged in as
” followed by their LOGNAME (use $LOGNAME) and a period.
7. Print “So, you are a member of the “
followed by the family name input; “
family. Does most of your family live near“ followed by home-town input and a question mark.
8. Print “Did anyone else in your family major in “
followed by their major and a period.
9. Print
I hope that for you the number
“ followed by the day on which they were born “will bring you luck!”
10. Print “Today is
“ followed by the full name of the
day of the week
(provided by the system) and then a period.
2. Type a commented script file in your home directory named
menu1
to do the following:
1. Clear the screen
2. Have a menu which asks the user if they wish to see the
name of the current directory
or to see
the calendar for the current month.
Have it nicely formatted (so that it looks like a menu).
3. Use
D
and
C
for the menu choices.
Use an if statement
4. The test condition should work
either with upper- or lower-case letters.
5.
The output should have a statement as to what it is being displayed
(on the line above the command result).
6. Give a message if neither letter is chosen.
3. Type a commented script file named
menu2
(in your home directory) to do the following:
Use a case statement in this script file and create a screen display that is clear and easy to see/follow.
When the user inputs the name of the file, check if it exists.
1. clear the screen
2. print a menu which clearly indicates what each choice does, as follows:
The menu options should be
P,
C, or
J
and use the
case statement
after their choice.
a. for option
P
have it print what is the home directory
b. for option
C
ask them to input a file name and then have the contents of that file shown on the screen
c. for option
J, ask them to input two file names and then concatenate them into one file named
joined
. Tell them the file name and show its contents.
d. If anything other than P, C, or J were typed, a message should be displayed that indicates they did not type one of the valid letter choices.
3.
Both upper and lower case letters
should be processed in the
case
statement.
4. Again,
have indications of what they are seeing
. (e.g. The home directory is”)