[cs615asa] scripting examples

Jan Schaumann jschauma at cs.stevens.edu
Fri Feb 27 14:12:00 EST 2009


Hello,

I've posted last night's slides and examples on the course website.
I've also uploaded a number of other little scripts and programs to
illustrate the various different scopes of what kind of tasks might be
automated in what fashion.  Under
http://www.cs.stevens.edu/~jschauma/615A/examples/, you will find:

bug2dot.1	--	a manual page for the 'bug2dot' program
			read using "nroff -man bug2dot.1 | more"

bug2dot.py	--	a program that will parse an HTML file
			representing bug dependencies and generate a
			dot(1) language representation thereof
			(written in python)

buildgcc.sh	--	a very simplistic script to compile gcc3 from
			sources on IRIX; in desperate need of
			improvement if it was still used;  good example
			of a quickly cobbled together script that would
			eventually grow

checkc001.sh	--	an equally simplistic script used a long time
			ago as a trivial "is this host up?" monitor, run
			from cron(8)

checkhosts.1	--	a manual page for the 'checkhosts' program
			read using "nroff -man checkhosts.1 | more"

checkhosts	--	a tool to ssh to a large list of hosts and
			execute a given command; a reasonable example of
			an actual tool written in shell

checklab.sh	--	a trivial script that loops over the
			lab.cs.stevens.edu DNS round robin and checks if
			all hosts are listening port 22;  another
			trivial "is this host up?" check

findinactive.py	--	a shell script written in python;  there's no
			reason this had to be written in python other
			than "I'm tired of writing shell, let me write
			this one in something else,... hmmm,..., how
			about,... python"

hanoi.sed	--	an illustration of what else sed(1) can do

news.c		--	a tool to alert users about news on the system;
			written in C so it could be included in the base
			system build; see news(1) on lab.cs.stevens.edu

pkg_ids.1	--	a manual page for the 'pkg_ids' program
			read using "nroff -man pkg_ids.1 | more"

pkg_ids		--	a program to checksum all files of all
			installed packages and compares the result
			against the previously recorded checksum in the
			packages' db file; written in awk(1) as an
			illustration that you don't need perl just
			because shell has become too limited

runcmd.sh	--	a shell script to run a given command on a list
			of hosts; uses awk(1) for the actual work and
			thus illustrates how you can combine them

splitmbox.c	--	a tool to split an mbox-style mail box (used by
			a number of mail clients) into one file per email
			(used by various other mail clients); written in
			C for performance reasons (some of my mailboxes
			have tens of thousands of mails in them)

subnet.sh	--	a trivial little script to loop over a given
			subnet and point out what IPs are not in use (ie
			registered in DNS); has room for all kinds of
			improvements

tz2tz.1		--	a manual page for the 'tz2tz' program
			read using "nroff -man tz2tz.1 | more"

tz2tz.pl	--	a program to convert timestamps from one
			timezone to another; written in perl to
			facilitate date manipulation through common
			libraries


All of the above with the exception of "hanoi.sed" were written by me at
some point as part of my job.  You should be able to clearly see which
ones were hacked together to quickly fix only my immediate needs and
which ones grew into larger (or at least more complete) programs
suitable for use by other people.

And yes, writing a manual page is an important part of writing the tool.
I actually write the manual page first to help me think through how the
program should behave and how the user interacts with it and then
implement the program according to the manual page.

-Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : https://lists.stevens.edu/cgi-bin/mailman/private/cs615asa/attachments/20090227/393d02ca/attachment.pgp 


More information about the Cs615asa mailing list