Create a directory called assign2/ in your home directory:
Change directory into assign2/:
Create a new Bash shell script called assign2.sh; if you use emacs, you can do it with:
with vi, like:
(Hint: you may want to also log into linprog{1,2,3,4}.cs.fsu.edu with a second window, if you don't want to use a "shell" buffer inside of emacs for testing your script.)
Your shell script should create output that looks like this:
2014 _________________________________________
/ Be careful of reading health books, you \
January February March | might die of a misprint. |
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa | |
1 2 3 4 1 1 \ -- Mark Twain /
5 6 7 8 9 10 11 2 3 4 5 6 7 8 2 3 4 5 6 7 8 -----------------------------------------
12 13 14 15 16 17 18 9 10 11 12 13 14 15 9 10 11 12 13 14 15 \ ^__^
19 20 21 22 23 24 25 16 17 18 19 20 21 22 16 17 18 19 20 21 22 \ (oo)\_______
26 27 28 29 30 31 23 24 25 26 27 28 23 24 25 26 27 28 29 (__)\ )\/\
30 31 ||----w |
April May June || ||
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 1 2 3 1 2 3 4 5 6 7
6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14
13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21 _________________________________________
20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28 / If one cannot enjoy reading a book over \
27 28 29 30 25 26 27 28 29 30 31 29 30 | and over again, there is no use in |
| reading it at all. |
July August September | |
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa \ -- Oscar Wilde /
1 2 3 4 5 1 2 1 2 3 4 5 6 -----------------------------------------
6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13 \
13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20 \
20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27 .--.
27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 |o_o |
31 |:_/ |
October November December // \ \
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa (| | )
1 2 3 4 1 1 2 3 4 5 6 /'\_ _/`\
5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 \___)=(___/
12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20
19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27
26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31
30
Here are some tools that you can use to do the assignment:
So analyzing the above output, the different components are:
Here is an outline of how I wrote my script:
#!/bin/bash # # This function takes two arguments, the name and port number of the fortune server # that you want to query # function writeFortune { # Collect one fortune from the fortune server and append it to the fortune temporary file. return } # # Do calendar bits # # Create a temporary file for the calendar. # Get the year from "date". # Increase the year by one and then call the "cal" program with that year. Write the # output to the temporary calendar file. # # Do fortune bits # # Create a temporary file to hold both of the "fortunes". # Call writeFortune with the server and port number information # # Now use "pr" to push everything together, and output everything to stdout # # # Remove temporary files and exit # exit 0
Next year must be computed, not a fixed value of "2014".
Once you have written your program, run it and redirect the output to a file named "cal1014.txt" in your assign2/ directory:
Finally, cd back into your home directory and create a tar file, named with the result of the uuidgen program:
Check the contents of the file: