#!/afs/athena/contrib/perl/perl # Watchmaker business card generation script # $Source: /afs/zone.mit.edu/user/bert/watchmaker/RCS/business-card,v $ $template="/afs/athena.mit.edu/contrib/watchmaker/lib/business-card.ps"; #$template="/afs/zone.mit.edu/user/bert/watchmaker/business-card.ps"; ARG: while (@ARGV) { $arg = shift(@ARGV); ($arg eq "-f") && ($filter=1, next ARG); ($arg eq "-name") && ($name = (shift(@ARGV) || die "$arg requires an argument\n"), next ARG); ($arg eq "-title") && ($title = (shift(@ARGV) || die "$arg requires an argument\n"), next ARG); ($arg eq "-email") && ($email = (shift(@ARGV) || die "$arg requires an argument\n"), next ARG); ($arg eq "-pgp") && ($fprint = shift(@ARGV), next ARG); ($arg =~ /^-P/) && ($prn = ($' || shift(@ARGV) || die "$arg requires an argument\n"), next ARG); ($arg =~ /^-o/) && ($output = ($' || shift(@ARGV) || die "$arg requires an argument\n"), next ARG); ($arg =~ /^-T/) && ($template = ($' || shift(@ARGV) || die "$arg requires an argument\n"), next ARG); die "unknown argument: '$arg'\n"; } $filter && $prn && die "-f and -P are mutually exclusive\n"; $output && $prn && die "-o and -P are mutually exclusive\n"; $filter=1 if $output; @ARGV=(); select STDERR; print <<"EndOfBanner"; -------------------------------------------------------------- Read /mit/watchmaker/doc/README.business-card for usage info. Send comments and/or complaints to bert@mit.edu. -------------------------------------------------------------- Please enter the following information: EndOfBanner print "Full name: "; if ($name) { print $name, "\n"; } else { $name=<>; chop($name); } print "Title: "; if ($title) { print $title, "\n"; } else { $title=<>; chop($title); } print "E-mail address: "; if ($email) { print $email, "\n"; } else { $email=<>; chop($email); } print "OK, using '$name' // '$title' // '$email'.\n\n"; if (! defined($fprint)) { print <<"EndOfPgpMsg"; If you wish, the fingerprint of your PGP key can be printed in a small font at the right side of the business card. If you simply press "return", no data will be printed. (A fingerprint is a way of verifying the identity of a PGP key. To get a fingerprint, use "pgp -kvc ".) EndOfPgpMsg print "Fingerprint: "; $fprint=<>; chop($fprint); } elsif ($fprint) { print "Fingerprint: $fprint\n"; } else { print "Fingerprint: [NONE]\n"; } if ($fprint) { @chunks = split(/ +/, $fprint); $pgpdata = " (" . join(" ", @chunks) . ") "; } if ($filter) { print "\nOutput to: ", ($output || "[STDOUT]"), "\n"; } else { if ($prn) { print "\nPrinter: $prn\n"; } else { print "\nPrinter [hp-test]: "; $prn=<>; chop($prn); } $prn = $prn || "hp-test"; if ($prn eq "nil") { print "*** nil may use bottom tray by default.\n"; print "*** proceed only if it's late at night or something.\n\n"; } else { print "Ready to print to '$prn'.\n\n"; } print "Place the business card stock in bottom tray and press RETURN.\n"; <>; print "Printing...\n"; } open(TMPL, $template) || die "Can't find template, exiting"; if ($prn) { open(LPR, "|lpr -P$prn") || die "Can't open pipe, exiting"; } elsif ($output) { open(LPR, "> $output") || die "Can't open '$output' for writing, exiting"; } else { open(LPR, ">& STDOUT") || die "Can't dup stdout, exiting"; } while () { s/__NAME__/$name/; s/__TITLE__/$title/; s/__EMAIL__/$email/; s/__FINGERPRINT__/$pgpdata/; print LPR; }