*** This FP performed on Acadnx ***
This Final Project is going to reveal alot of functionality that has been going on without your awareness as you have been helped by login scripts. You will be using William E. Shotts, Jr. script tutorial © 2000-2015 which is also reproduced at the bottom of the page in PDF format.
- You need to login to Acadnx for this Final Project.
- You will take and paste screenshots into your 3 final project submission documents. These should be named “LastnameFirstnameFPScripting#.pdf” where the pound sign (#) will be replaces with the submission number. Sections 1-5 will be #1, Sections 6-10 will be #2 and Sections 11-16 will be #3. As an example I would submit 3 files titled (LoobyJamesFPScripting1.pdf, LoobyJamesFPScripting2.pdf and LoobyJamesFPScripting3.pdf)
- You will need to expand your Linux Terminal as large as you can vertically in an effort to capture the output as best as possible.
- You will have 1 or more screenshots for each individual component of the table of contents.
- You will need to label your screenshots with a heading that includes the Content number and letter.
- You need to follow the directions very carefully and any errors you encounter are input errors (spelling, case sentitivity, etc.) or improperly following the provided directions or a lack of required understanding of previous LL material.
- Should you not complete all components, you can obtain partial credit as long as you also complete and submit #16.
Should something go wrong, please retrace your steps and look at your code carefully noting that spaces or the lack of spaces is important. Beware of dots and note that Ls and 1s can also look similar depending on the font. If you don’t understand or misinterpret a term or instruction you will also have to retrace your steps to find and correct your error. Note, you may need to reperform your earlier LL readings and labs should you have gaps in your understanding and should you seek help, it is likely that I will direct you to reread and reperform earlier LLs. If you have done the necessary preparation (readings and LLs) this FP will be straightforward. Lastly, please observe the coding practices rather than just blindly following the instructions as this tutorial will show you proper comment and output documentation.
Here are 2 great resources – open the docs and search using ctrl-f in Windows/Linux or command-f in Mac.
Again, you are taking a screen shot for every letter below and pasting into your FP submission documents. Please clear your screen between each contents number (i.e. clear screen before starting #2, #3, #4, etc.). BTW – I use the nano editor for the informative color coding.
Submission Document 1
A. Show a complete long listing of your newly created bin directory
B. Create the “hello_world” script as directed but add “from your name” to the echo statement. For me my output would be “Hello World from James Looby”. Show the contents of your “hello_world” script in the bin directory
A. Please make a backup of your .bashrc titled .bashrc.bak in your home directory so should you modify it incorrectly you can restore it. Also, you should research what the .bashrc file is, what it does and when it is run as a basic understanding is critical to your completing this step. To this extent, I would recommend you Google “What is .bashrc” and “When is .bashrc run”.
B. Aliases – please make your “l” alias be a complete long listing (in the tutorial it is just a long listing). After logging out and logging in, please use your l alias to show the entire contents of your home directory.
C. Create the “today” function as directed and use it.
3. Here Scripts
A. Instead for making your sysinfo_page title “My System Information” please use your initials so as an example my title was “JL System Information”. Take a screenshot of your sysinfo_page while it is open in an editor.
B. Please move your sysinfo_page to your bin directory, change its permissions to make it an executable, perform your aliased complete ong listing (i.e. ‘l’) and run your sysinfo_page script. Note this will display the contents of the file and this is sufficient as we will redirect the output to the sysinfo_page.html file when it is completed later in this FP.
Please note I will not remind you to move your scripts to your bin directory and adjust your permissions again as based on your understanding of the material you should do this automatically. Should you not understand this please return to the reading in LL1 and subsequent LLs and perform the requisite reading and research.
A.Take a screenshot of your sysinfo_page while it is open in an editor.Again substitute or prepend your intials to the system information variable (e.g. mine would be “JL System Information”).
B. Run sysinfo_page and take a screenshot.
A. Complete this exercise in its entirety and take a screenshot of sysinfo_page open in your editor.
B. Run your sysinfo_page script and take a screenshot
Please submit your Submission Document 1
Submission Document 2
A. Complete this exercise in its entirety and take a screenshot of our sysinfo_page open in your editor.
B. Run your sysinfo_page script and take a screenshot.
A. Complete this page as it is written noting that you of course have error messages when running sysinfo_page. Take a screenshot of your sysinfo_page open in your editor.
B. Take a screenshot after running your sysinfo_page script.
A. Complete this page and take a screenshot of your sysinfo_page open in your editor.
B. Take a screenshot after running your sysinfo_page script.
A. Create the “trouble.bash” script in “Stay out of Trouble”. Run it ensuring you achieve the output “Number = 1”. Take a screenshot and paste into your document.
B. Modify and break the script in “Empty Variables” and then fix it per the instructions. Take a screenshot of your corrected more robust code. Also run and take a screenshot of your trouble.bash output so you have 2 screenshots for this 9B component.
C. In “Missing Quotes” please remove the quote as directed and run the script. Take a screenshot of the error message and then fix your script by putting the quote back in.
Isolating Problems – there is no screenshot for this component however this is very important material so please read it carefully several times and apply these practices should you get errors.
D. Turn tracing on in “Watch your script run” using either method shown, run your trouble.bash and take a screenshot of your output.
A. Create the “read_demo.bash” script, run it and take a screenshot of its output with your interaction.
B. Modify “read_demo.bash” with the -t option as directed. Run “read_demo.bash” but don’t input any text when prompted allowing it to time out. Take a screenshot of this ouput.
C. Create a “number_demo.bash” script that computes whether an input number is even or odd (2nd Arithmetic example). Take a screenshot of your “number_demo.bash” while it is open in the editor and then take a 2nd screenshot when you run the script. (Note you will have 2 screenshots for this component.)
Please submit your Submission Document 2
Submission Document 3
A. Create a “case_demo.bash” file to test the input is a character, digit or not a character/digit. Take a screenshot of your script while it is open in the editor. Then test your script by running it 3 times giving it separately a character as input, a digit as input and a non digit/character as input (try a symbol or F1 key or…). Take a screenshot and this component will have 2 screenshots.
B. Create a “loop_demo.bash” file using the 2nd example with the “press_enter()” function. Take a screenshot of this file while it is open in the editor. Then test the script and take a screenshot while the script is running.
C. Please copy the following question and supply the answer in your FP document.
In the “loop_demo.bash” script, what would happen if we tested for the wildcard asterisk (*) first (i.e. we test in order *, 1, 2, 0). Ans:_______________
Note you may want to or need to turn tracing on to follow execution and debug if necessary. Note when you add interactive mode (e.g. “Adding Interactive Mode”) you will need to remove the else clause which includes the closing “fi”.
A. When complete run the program without interactive mode and run the program in interactive mode where you name the output file with your initials.html (e.g. for me it would be JL.html). Perform a listing of your parent directory from your bin subdirectory and perform a listing of your bin directory and take a screenshot. Then show the contents of your sysinfo_page script on the screen and take a screenshot. You will have 2 screenshots for this component.
A. Complete the system_info() function but not the home_space() function. Run sysinfo_page and take a screenshot. Also display the contents of your sysinfo_page.html on the screen. Paste both screenshots into your submission document.
A. Please read and understand all examples on the page. You will not execute a rm*.
B. Add the last error_exit() function to sysinfo_page and take a screenshot. There is no need to run it since we are not calling error_exit() from any of the sysinfo_page code.
Please read this section in its entirety noting the fix at the bottom of this section in bold.
First, we now see the “ctrl-c” we have used previously is a signal interrupt. You should think back to the Lecture Module on OS and realize that Linux is a pre-emptive interupt driven (rather than polling) OS.
A. In the section titled “Cleaning up after yourself”, create a print_demo.bash script noting you will need to substitute the less command for the lpr command since there is no attached printer so lpr is not installed. Run the script with the command line argument print_demo.bash (yes we will display the contents of the script on the screen). Take a screenshot of the output as well as displaying the script contents on the screen.
B. Add trap handling to your print_demo.bash as directed and again run the script supplying print_demo.bash as the command line argument.
A note on the Signal 9 discussion on locking a file. You may have seen this when MS Word or another application opens a file providing you with “read only” priviledges. This is because the file is locked where you can have many readers but only 1 writer. Recall the OS is the resource manager and certain resources needed mutually exclusive access. In this case the OS sets a lock on the resource (e.g. Semaphore, Monitor, etc.)
C. Add the clean_up function to your print_demo.bash and run print_demo.bash as before. Hopefully you see the elegance of modularization (encapsulationg code in functions) as we can now add things to our clean_up function definition and the changes will be executed when clean_up is called.
D. Complete the full print_demo.bash script (w/ usage, clean_up and error_exit). Run the program as before and take a screenshot of your output.
Fix: There is an issue with #15 associated with /tmp/printfile.txt being write protected so your program can’t delete it and use it for the output of the pr command. To fix this (for the final project), change the line:
This will create the temporary file in your current directory instead of in /tmp.
16. Email sysinfo_page.html and sysinfo_page files to yourself
Here we will send separate emails to your hvcc.edu account (not mine) with your sysinfo_page.html file and your sysinfo_page script. You will do this with the following commands replacing my subject information and email address with your named subject information and your email address. You then need to save the emails in pdf format upon receipt and upload them to the BB Final Project submission area along with your other 3 documents (you can always print them and choose the save as pdf option).
mail -s “JLooby sysinfo_page.html” email@example.com < sysinfo_page.html
Change directory to your bin directory and enter
mail -s “JLooby sysinfo_page” firstname.lastname@example.org < sysinfo_page
[listyofiles folder=”wp-content/uploads/LinuxScriptFP” options=”table,filesize,icon”]