## Tentative schedule

Week/Date Lecture contents Assignment
JUL-23 Course intro
• Organization
• Assignments and project
• UNIX, email, news, editor, famiiarization (nothing to be submitted)
• Email readers: pine, mutt, elm
• News readers: tin, trn, xrn
• Emacs and Vi/Vim
• Text-based browser (lynx)
• Netscape browser, messenger, and  composer familiarization (nothing to be submitted)
JUL-30
• Web browsing
• Lynx and wget: being kind to others
• Notes on security issues in browsing untrusted sites: active pages, cookies
• HTML Forms
• UNIX shells and utilities
• Build your homepage and a resume (optional) in HTML.
• Write a few shell scripts (details below).
AUG-06
• Clarifications on last assignment
• Lecture on programming in Perl. Scribe notes are available, thanks to Ameya Prakash Usgaonkar.
• Write a bunch of perl scripts, shorter and more readable is better (see below)
AUG-13
• UNIX Networking in Perl. Scribe notes are available, thanks to Achint Kaur.
• Some more Perl assignments
AUG-20 (SI) Building tools
• Assignment regarding Java class dependence resolution (see below)
AUG-27 More programming skills
• RCS, CVS and version managing skills
• ANSI C++ Standard Template Library
• Finding the task graph and some of its properties from a makefile and a directory of files (see below)
SEP-03 (SI) Typesetting scientific documents using LaTeX
SEP-10 (SI) Preparing presentations using SliTeX and PowerPoint Mid-semester exams (no homework)
SEP-17
• More about TeX and LaTeX
• Class project discussions
Writing macros in TeX and LaTeX
SEP-24
• Lexical scanners: lex, flex, flex++, JFLex
• Parsers: yacc, bison

SEP-29 Guest lecture by Prof. Joshi about Object-oriented programming
OCT-01 Postponed owing to Query Optimization Workshop
OCT-05 17:30 Java language basics
OCT-08 Java UI, AWT, JFC/Swing, JDBC
OCT-15 15:00
• Class project informal status report
• Servlets?
• Proposals for covering additional topics
Small Java homework
OCT-22 Hand out LaTeX and Java homeworks.
OCT-29 Project status due
THE-END Class project viva/demo Project report to be typeset in LaTeX and BibTeX

## July 23 Assignment Instructions

### Simple UNIX commands (read man pages)

 Logging in (rlogin, telnet)Directory commands (cd, pwd, ls, !, ., .., mkdir, rmdir) File manipulation (cp, mv, rm, chmod, chown, ln, ln -s) File comparison (diff, split, join) File display (less, more, cat) Printing (lpq, lpr, lprm, lpstat) Miscellaneous (echo, date, exec, yes) Disk usage (du, df, quota)

 Vi and Vim GNU Emacs (we urge you to use this)

## July 30 Assignment Instructions

### Homepage

Your homepage assignment is due AUG-06. Here are detailed instructions. You can either use a text editor like vi, vim or emacs directly, or use a WYSIWYG editor such as Netscape Composer.  Do not crowd your page with too many images!  Make sure you have used the following features:
• Three different font sizes
• Three different font types
• Should have atleast three links
• Link to the department homepage
• Should have atleast two images
• Should have a title
• Should use listing tags like OL, UL, DL
• Create a CGI form.  Process the form at the server end using (a) a C program executable and (b) a (bash) shell script.
• Create a table, e.g., that has your timetable for every working day of the week

### Samples available!

Check out the GET and POST examples and follow these to create your own.  In your case, the form should have a text field to enter a machine name and a user name.  Using this, your CGI script should finger the user at the machine and send back the response to the client browser.

Do NOT run your own HTTP servers any more.  Rony has created a server on port 5901 of Everest.  You place your CGI files in /pkgs/apache/otherserver/cgi-bin/<your_user_name> and enable +x on your CGI files, and point to them from HTML files on Surya (see my examples).

### Shell scripts

• Write a shell script (any shell of your choice) to exchange the names of the two arguments (called argv in C/C++ languages).  They can refer to files or directories.
• Write a shell script to search the given directory recursively and print only those files which have executable permission for all users.

## August 9 Assignment Instructions

You have to write a few Perl scripts.  You won't get any points unless these work.  If these are functional and reasonably readable you will get 85-90%.  You will get full points only if you exploit Perl to make these really short and clean and yet readable.  All problems carry equal weight.

These are due Friday 20th August.  Submission instructions will be sent out by me or a TA soon.

• Write a small command line calculator in Perl.  The language specification is as follows:

• EXPR   ::= TERM { ADDOP TERM }
TERM   ::= FACTOR { MULOP FACTOR }
MULOP  ::= "*" | "/"
FACTOR ::= NUMBER | "(" EXPR ")"

The ::= symbol means "may be composed of," the curly braces mean "zero or more occurrences of" and the vertical bar means "either-or."  Use a recursive descent parser.  (You don't really need to know what that is, but use the Web to search for details if you like.)

If the script is invoked without arguments it should go into interactive mode, otherwise it should evaluate the expressions passed in the arguments and exit.

• Given a whole decimal number, write a script commas.pl to insert commas every three digits from the least significant end.  E.g. if the input is 1234567 the output should be 1,234,567.

•
• Suppose you have a colon-separated one-record-per-line file such as /etc/passwd.  Write a script fieldsort.pl which can be invoked, e.g.,  as "fieldsort.pl -f 3 /etc/passwd" to print the lines of /etc/passwd sorted in increasing order of field number three.  Do NOT use the UNIX sort utility.

•
• Some editors are quite indiscriminate as to how they implement tabs.  They may use a mix of hardware tabs and space characters.  A hardware tab usually results in a visual indent of 8 positions.  Write a script retab.pl which will accept a program in C, C++, or Java that has mixed tabbing, and retab it to use 4 spaces for each indent level, printing the result to standard output.  There should be an option to change the default of 4 to something else, e.g., "retab.pl -s 2 MyProg.java".  (Hint: use the $var x$count  feature.)

•
• Given two directories as arguments, e.g., "findcommon.pl dir1 dir2" your script should check if there are multiple copies of any file in the two directories or contained subdirectories.  These sets of identical files should be reported with full path one per line.  You should not report hard or soft links.  Do NOT invoke UNIX utilities.  As an example, the script might print:

•    dir1/diary.html dir2/diary1.html dir2/sub5/notes.txt dir1/sub3/expenses.txt dir1/sub5/sub6/exp.doc

Note there can be more than two files reported per line. Extra credit: make this fast.

• Perl networking assignment:

• If your roll number is odd, do the first assignment; if it is even, do the second.  NNTP-to-SMTP: Write a Perl script that will run as a demon. It is invoked with a list of newsgroup names. Every 24 hours (use a shorter interval for testing) it will wake up and check the newsgroups for new articles with subject lines that match a given regular expression. If such articles are found it will mail the article to a given email address. HTTP-to-NNTP: Write a Perl script to watch a specific URL, polling it periodically to see if it has changed. (If the page provides an "Expires" MIME header field, you should use that to schedule the next poll.) If the page has changed, the script should post it to the specified newsgroup.

## August 23 Assignment Instructions

This is an assignment involving make and Perl, due Monday 30th Aug.
• Read the man page for makedepend.  Makedepend automatically generates dependencies for C/C++ files.  Write using Perl a toy makedepend utility for Java.  For this exercise, you just need to know that a Java program is a bunch of .java files, all in one directory.  (Ignore external refs and packages.)  A Java file consists of a sequence of class declarations.  Class definitions can be nested.  An example is shown.  You have to generate a graph where each node is a class name (such as Main.Inner) and there are edges expressing dependencies.  Also complain about classes not found in the current directory.
•  public class Main {     protected Other b = null;     protected Inner e = null;     public Main() { b = new Other(); e = new Inner(); }     static public class Inner {         public int a = 5;     } } public class Other {     public Main.Inner c = new Main.Inner();     public Inner d = new Inner(); } class Inner {     public double pi = 3.141592653589; }
• If you are confused, read up about namespaces and inner classes in any Java book.  This will also start preparing you for writing Java.  You don't need to know anything else about Java.  C++ familiarity will help.
• Remember Java like C/C++ is free-format.  So you have to count [({})] nestings to decide where a class declaration ends.  Pretend there are no // or /* comments. */

### August 27 Assignment Instructions

This is the homework that went out of control last week...

As mentioned in class, there is a "parallel" version of make called pmake, which tries to process tasks that do not depend on each other concurrently. As you know from the class, a makefile specifies a workflow dependency as a directed acyclic graph (DAG).

The input to your Perl script will be a directory with a few files in it, and a makefile.  The makefile will specify one final target, which will be related to some of the files in the directory using usual rules.  To make the target, it will be in general necessary for make to run programs that will create additional files in the directory.

Assume all files and dependencies are restricted to the given directory.

One of the things pmake/make has to do is to compute the subpart of the task DAG that needs to be remade.  Use suitable flags with make on Linux, together with a Perl script, to compute the effective task DAG. To clarify further, the effective DAG could be much smaller than the DAG expressed through the makefile, because some intermediate targets are already up-to-date.

Using the UNIX time command, you can estimate how much time each task takes. Based on the DAG and the times estimated for each node, report two things:

• The minimum time to make the target assuming you had infinite processors and disk bandwidth does not degrade with parallelism.  This is the critical path length.
• The maximum number of processors you can use while guaranteeing that the efficiency is more than one-fourth.  Efficiency is (1-processor runtime) / (p * (running time on p processors)).

Extra credit: submit a one-page write-up giving an algorithm to find the width of the DAG, namely, the largest set of nodes/tasks which can be executed concurrently.  You don't have to code up the algorithm.

If you find Perl intolerable for this homework feel free to use C/C++.

## September 17 Assignment Instructions (TeX and LaTeX)

You may have come across TeX's main macro definition mechanism, \def. For example, to typeset a small amount of text (no paragraph breaks) in boldface, you may say:
1. \def\bold#1{{\bf #1}}
or preferably, if you want to permit paragraph breaks,
1. \long\def\bold#1{{\bf #1}}
Here #1 is the formal argument which is instantiated as
TeX has another macro construct called \let.  If you say:
1. \let\mybf=\bf
then you can use \mybf just like you use \bf to typeset in boldface.

Question: Why are there (at least) these two distinct mechanisms to define macros?  Is there a significant difference between \let\a=\b and \def\a{\b}?

Question: Suppose you want \bf to print italics and \it to print boldface, for whatever reason.  How would you do it?

TeX defines macros for looping constructs as follows:

1. \def\loop#1\repeat{\def\body{#1}\iterate}

2. \def\iterate{\body\let\next=\iterate\else\let\next=\relax\fi\next}
You invoke the \loop...\repeat construct in the form
\loop <loop-condition> <loop-body> \repeat
Question: Using \loop...\repeat, write a macro called \punishment which, when invoked as
\punishment{I will not take part in trivia quizzes.}{100}
will print the first argument once per line as many times as the second argument.  To help you, here is some information on creating and manipulating counters and conditions in TeX.
\newcount\n     %creates a new counter
\n=1            %sets \n to 1
\advance\n by-2 %new value is -1
\newif\ifabc    %creates a new condition called abc
\abctrue        %sets abc to true
\ifabc \textbf{Now!} \else \emph{Never!} \fi  % uses abc
\abcfalse       %sets abc to false
Question: Write a macro \primes which has one argument #1 and will print the first #1 prime numbers.

As discussed in class, LaTeX uses the .aux file and multiple passes to connect up references and citations with suitable numbers and labels.  LaTeX emits a warning if it cannot resolve all references correctly in the current pass, or it has room to suspect that one or more of its label resolutions is incorrect. For example, the following LaTeX source has a forward label reference, and will not resolve in the first pass.

 \documentclass{article} \begin{document} \section{Introduction} \label{intro} In Section~\ref{concl} on page~\pageref{concl} we conclude. \section{Conclusion} \label{concl} We started the paper with Section~\ref{intro}. \end{document}

If you view the .dvi file after one pass, it will have question marks where reference numbers are supposed to be. If you run LaTeX a second time, all labels will be replaced by correct numbers, and LaTeX won't complain any more.

Question: Write and invoke a macro \dupelatex which will prevent LaTeX from ever correctly cross-referencing your submission .tex file, no matter how many times it is run.  (There is good reason why LaTeX does not automatically reinvoke itself even though all references are not resolved properly.) Your source may either leave unresolved labels (question marks) or incorrectly resolved labels (wrong numbering). We prefer that you produce the second problem.

Please typeset all your answers in one LaTeX source file and submit that.  This homework is due Monday 27 Sept.   If LaTeX throws up an error you won't get any points.

General suggestion: On your Linux machine, search for .tex, .cls, and .sty files using the UNIX find command in /usr/share and /usr/lib.  Use these to learn from example.

## October 22 Assignment Instructions (Java and LaTeX)

• Inspect the following postscript file that was typeset using LaTeX. Recreate it exactly (figures can be different). Watch for fonts, margins, and spacing details very carefully. Submission: Turn in the .tex, .bib, and .eps files. Note: Answer for this homework has been published to facilitate writing MTech seminar reports. Check out sample.tex and sample.bib.
• Note: this is due Monday 1-11-1999. Write a Java applet that shows a rectangular panel (say, 600x600) with two small colored squares (say, 10x10) in it. By using the mouse, you should be able to drag each square to any position such that the square is always completely contained within the applet panel. As you do this, the other square should move so as to remain within the applet panel boundaries, while the line joining the centers of the squares always passes through (300, 300). You have to refresh the screen without any flicker or blackout. Minimize discontinuous movements of the squares. Submission: Make a link from your home page (designed earlier) to the applet with suitable applet tags.