We were assigned a homework problem yesterday in class. I have very little under
ID: 3620574 • Letter: W
Question
We were assigned a homework problem yesterday in class. I have very little understanding of this material anyway, but this assignment is way out of my league. I don't even know where to start with the problem and so far I haven't been able to get any help from the instructor via e-mail. I pasted the entire outline of the assignment below... any help would greatly be appreciated.CS 3530 : Homework 2
Due 10/7/10 @ 23.59 - submit to dickinsonmg@missouri.edu
use subject "CS3530 HW2"
Goals:
1 Develop Shell Scripting Skills 2 Familiarize yourself with Unix Shell topics 3 Understand how to build menu driven programs using shell scripting
Task
Write a small text-based shell script web-link navigator. Your program must be written using one
of the shells: Bourse, Korn, C-Shell, Bourne Again (bash). It should spawn a sub-shell to execute and be menu driven.
Expected Usage: navigator <address> If the program is started without an address, simply display the proper usage and exit.
The program should download all files to a cache sub-directory under the user’s home directory called “.bcache”. Pages/links that are downloaded will be parsed to find HTML anchor tags of the form: “<a href=... > Link Name </a>”. Each anchor found will become a menu option. The user will then select the menu option and navigate to that link. Here, the process will repeat. The menu should always have the “q” option to quit browsing links.
Your script should generate a full log file that captures all downloads and link parsing. Keep this log in the cache directory and truncate the file every time the script starts.
Notes
~ The script should successfully run from any location, yet still properly use the cache. ~ You do not need to use the cache for any advanced caching operations, simply use it as a staging area to work on the files. ~ Must run on Babbage
Restrictions
~ No PERL, C, Java...etc. – only shell scripting. ~ No use of web utilities other than wget or curl.
Explanation / Answer
well, where to start... I know just bash shell scripting, but if that is the way you wish to go, you will need to use the commands: bash: echo, read, if, case, for, while utilities: wget or curl grep, and perhaps sed In order to learn about the commands, it might be usefull to read the manual pages about them, to learn about echo and read, run "man bash" from command line and then type "/echo" or "/read" and tap "n" until you arrive at a useful description. when you are done tap "q" to read about any of the others, just run "man wget", "man curl", "man grep", etc. The manual page on bash will also give you a good deal of information about shell scripting, although it is very long -- skimming is the way to go, only stopping for things that seem relevant. some of the manual pages can be a little dense, sed especially, so you might like to google some of the tools, reading about someone elses usage of the tools, is superior to any description. the command "echo" will a line to the screen, eg. "echo hello" will print hello to the screen. the comamnd "read" will allows you to get input from the command line. eg. "read variable" will print nothing, but allow the user to enter a line of text storing it in $variable. Thus try pasting in the following on the command line: echo "Please enter your name: "; read name; echo Hello $name using echo and read thus, you can build a menu: echo "(1) first option" echo "(2) second option" echo "(3) third option" echo "(n) nth option" echo "(q) quit" read choice then use if to determine which option was chosen. sorry, I can't finish this, just saw the time, I have to be somewhere in 10 mins. hopefully this will get you started. with sed look into the -s option, use grep and sed to parse the html files. You can and will most likely need to chain operations with pipes "|" and you can save output to files using command > filename hope this helps you if only a little. Just keep the points.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.