#!/usr/local/bin/perl #examin arg(s) for flags and queuename or empty list foreach $arg (@ARGV) { next if /^-/; $printer_dev = $arg; } #get name of printer from device name if (defined $printer_dev) { ($printer, $suffix) = split("-",$printer_dev); } else { $printer = $ENV{PRINTER}; } #get spooler for $printer open(HES,"hesinfo $printer qhost|"); while() { chop; unless(/Hesiod name not found/) { $spooler = $_; } } #print out helpful message listing $printer and its spooler print "printer: $printer spooler: $spooler\n"; #get my current realm by looking at $CELL, get printer realm by #assuming it will be in a glue realm if the spooler is a glue machine, #otherwise wam. $mycell = $ENV{CELL}; $printercell = ($spooler =~ /eng|glue/) ? "glue.umd.edu" : "wam.umd.edu"; #make current ticket env file appropriate to printer realm #see if user already has ticket for appropriate realm #if not, kinit if ($mycell ne $printercell) { $substr = ($mycell =~ /glue/) ? "wam" : "glue"; #to figure out if there is a ticket for the right realm, test to see #if this file exists. for example, /usr/local/scripts/wkinit creates #this file. $filetest = "/tmp/tkt_".$substr."_".$ENV{USER}; unless (-e $filetest) { #run a kinit. should put this in a loop in case they typo. $kinitcmd = ($mycell =~ /glue/) ? "wkinit" : "gkinit"; system("$kinitcmd"); } $ENV{'KRBTKFILE'}=$filetest; } system("qdev @ARGV");