PDF Version Available
This document is also available in PDF format: shellvar.pdf
The PDF version includes bookmarks for easy navigation and is optimized for printing.
Accessibility Notice
This document is also available in HTML format at:
Link: https://aholdengouveia.name/IntroLinux/labs/shellvar.html
The HTML version provides enhanced accessibility features including keyboard navigation, screen reader support, responsive design, dark mode support, and high contrast options.
Learning Outcomes
By the end of this lab, you will be able to:
- Use positional parameters, such as $1 and $2, to work with pieces of information in a script
- Read input from the user and use it in a script
- Use backticks to capture the output of a command, such as the date from the server
- Test a script to show a successful run, and explain what each line does by writing comments
Lab Instructions
This lab has 3 scripts. Each one must be a separate script.
Script 1: Dated File
Write a script that will create a file with the date appended to the name. Date should come from the system, not typed in by you. The name of the file should include your username on the CIS server and the name or nickname of a building on one of our campuses, for example: yourusername-buildingname-date.
Script 2: Greeting
Write a script that will ask the user for their name and then echo out a greeting with their name. Include a comment with a hello and your name
Script 3: Madlib
Write a script that will create a madlib about a place in the state our school is in that you've actually visited. Link: https://en.wikipedia.org/wiki/Mad_Libs The user should be asked for the words that you want to insert, you must come up with the paragraph. The paragraph needs to be at least 3 lines. Madlib shouldn't have more than 5 blanks to fill in.
Your script must also include these two comments, written as comments inside the script itself (not just in your submission document):
- A comment with one specific thing you did or saw at that place.
- A comment at the top of the script describing one thing that didn't work the first time you ran your madlib, and how you fixed it.
Deliverables
One file that includes all the requested information with your name, the date, and the lab title.
How to turn in your scripts
Follow the format in the sample submission Link: https://www.aholdengouveia.name/IntroLinux/labs/CIS%20117%20shell%20sample.docx
- Submit a copy of your code as actual text. NO screenshots of code are allowed.
- Submit a screenshot or the results of your test run, so that I can see a successful run of your code. Every script should be tested. A script that doesn't run is worth 0 points. Your screenshots must show your prompt with your username, or a note with your name and the term.
- Comments should be done on EVERY line of code, (this is very bad practice in the real world, never do this for a job) so that I can see that you understand the code that you are submitting. Every line should have an explanation of what that line does. Comments are worth 5 points per script.
Resources
References, a video, a PowerPoint and some notes are available at my website Link: https://www.aholdengouveia.name/IntroLinux/shellvar.html
My FAQ Linux playlist on YouTube, with demos of many of the commands and scripts in this class Link: https://www.youtube.com/playlist?list=PLQOmuLC45eoQlIMH7oCNL6yFP7kWQubBo