COP3353 - 2017 Summer
Assignment 4 "Next Year's Calendar"
Due by 11:59pm, Monday, July 17

Step 0

Login to cop3353.org.

Step 1

Change directory to your ~/bin subdirectory:

% cd ~/bin

Create a new Bash shell script called cal2018; if you use emacs, you can do it with:

% emacs -nw cal2018

with vi, like:

% vi cal2018

(Hint: you may want to also login 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:

                            2018                                       _________________________________________
      January               February               March              / If you stand on your head, you will get \
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa      \ footprints in your hair.                /
    1  2  3  4  5  6               1  2  3               1  2  3       -----------------------------------------
 7  8  9 10 11 12 13   4  5  6  7  8  9 10   4  5  6  7  8  9 10              \   ^__^
14 15 16 17 18 19 20  11 12 13 14 15 16 17  11 12 13 14 15 16 17               \  (oo)\_______
21 22 23 24 25 26 27  18 19 20 21 22 23 24  18 19 20 21 22 23 24                  (__)\       )\/\
28 29 30 31           25 26 27 28           25 26 27 28 29 30 31                      ||----w |
                                                                                      ||     ||
                                                                       ______________________________________
       April                  May                   June              / You teach best what you most need to \
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa      \ learn.                               /
 1  2  3  4  5  6  7         1  2  3  4  5                  1  2       --------------------------------------
 8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9         \
15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16          \
22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23              .--.
29 30                 27 28 29 30 31        24 25 26 27 28 29 30             |o_o |
                                                                             |:_/ |
                                                                            //   \ \
        July                 August              September                 (|     | )
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  6  7            1  2  3  4                     1          \___)=(___/
 8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
                                            30

      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  5  6               1  2  3                     1
 7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
                                            30 31

Here are some tools that you can use to do the assignment:

(Nota bene: the file1 and file2 arguments that were previously above in the pr invocation meant, as explained in class, to be explanatory — those were not to be literally included in your script since you are not allowed to use temporary files.)

So analyzing the above output, the different components are:

Here is an outline of how I wrote my script:

#!/bin/bash



  # Get the year from "date".
  # Increase the year by one and then call the "cal" program with that year. Write the
  # output to a variable.
  # Create fortunes and pipes to cowsay.
  # Now use "pr" to push everything together
  # and output everything to stdout.
  #
  #  -or-
  #
  # Do all of the above in a single one-liner for extra credit on this assignment.


exit 0


Next year must be computed, not a fixed value of "2018".

You may not use any temporary files for this assignment; if you need to save state, use a variable.

If you manage to write this as a "one-liner" (all of the active code fits into a single line with no semicolons, no &&, and no || constructions), then you will get 5 points of extra credit on the assignment.

Once you have written your program, add it to your .bash_profile right after your weather report so that when you login, it should look something like this:

This assignment is due by 11:59pm on Monday, July 17. You don't have to turn anything in; the grader will check this directly on your account on cop3353.org.