[LON-CAPA-users] reviewing most recent latex in prtspool

Michael T Hamlin lon-capa-users@mail.lon-capa.org
Thu, 21 Aug 2003 13:09:06 -0400 (EDT)


here's a little perl script to save you the hassle, if you find yourself
doing this often.  I called it "lastlatex.pl" but change to your liking.
Save it in your path somewhere and make it executable.

michael


#! /usr/bin/perl -w
# usage:  lastlatex.pl <n>
#    View the most recent latex output generated by the current user
# in /home/httpd/prtspool/ (eg, printing lon-capa problems)
#    If <n> is an integer, latex document will scroll to line number <n>.
#    If <n> is a non-integer, it is used as a search pattern and the document
# will scroll to the first appearance of that pattern.

$parm = shift;
$curuser = getpwuid($>);
chdir('/home/httpd/prtspool/') or die "Couldnt cd to prtspool: $!\n";
open(MYFILES,"ls -t $curuser*tex |") or die "Couldnt get directory: $!\n";
$filen = <MYFILES>;
close(MYFILES);
$scrollcmd = '';
if (abs($parm)>0) {
   $parm = abs($parm);   # always count from top
   $scrollcmd = "+${parm}g";
} elsif ($parm) {
   $scrollcmd = "+/$parm";
}
exec("less -Nj5 $scrollcmd $filen");

__END__