IT3110 @ utahtech
Begin by joining my github classroom using the following link. You will put your assignment submissions for each week into this repo.
After the repo has been forked to your account, you can then clone it and modify the files within it. You should look at the week1/assignment.sh
. This shell script has the following specifications.
The script has the following functions:
get_file
: this function will retrieve the supplied command line URL and save it to a location of your choice. Maybe /tmp/sample.txt
. Hint: use wget
. In my sample below, I turned off the output for wget. See if you can figure what the quiet
option does for wget by looking at the man page.get_column
: this function should print out the column for the machine indicated by the command-line arguments, from the file downloaded. This could be done with some usage of grep
and awk
. Depending on how you do this, the awk command could get kind of tricky. The hint 2 here may be useful. Make sure that you also remove the first two lines of the file since they are icky.show_output
: this function will call the get_column
function and will echo it out.main
: this function will call get_file
followed by get_column
followed by show_output
.You also need a call to the main
function. You should call it in this fashion:
# do not run main when sourcing the script
#[[ "$0" == "${BASH_SOURCE[0]}" ]] && main "$@" || true
main
A sample run of the script may be like follows:
joe@yavin:~/s23/it3110/scripts/bash/week1$ ./a1.sh clarke 2 https://it3110.cs.utahtech.edu/files/have_found.txt
Column 2 for the machine clarke is:
b8:ac:6f:ab:91:1d
joe@yavin:~/s23/it3110/scripts/bash/week1$ ./a1.sh clarke 1 https://it3110.cs.utahtech.edu/files/have_found.txt
Column 1 for the machine clarke is:
clarke
joe@yavin:~/s23/it3110/scripts/bash/week1$ ./a1.sh zinc 2 https://it3110.cs.utahtech.edu/files/have_found.txt
Column 2 for the machine zinc is:
c8:2a:14:3f:a8:e0
You need to create a function called make_dhcp
. This function will display the appropriate fixed dhcp entry in the following format:
host bova {
hardware ethernet c4:2c:03:25:a2:22;
fixed-address 144.38.195.230;
}
Also, create another function called make_dns
. This function will display the appropriate DNS entry for this machine in the following format:
bova IN A 144.38.195.230
Note: there are tabs between each field in the above. There is also a newline at the end.
Make sure that your main
function is ONLY calling get_file
and get_column
.
You should upload your script to the week3/assignment.sh
directory in github.