: Quickies: match programs to interpret/compile/run files : use "quickie setup" to map the 'q' key in 'vi' into a quickie. Mailer=/bin/mail # good for Linux # Java=/share/java # where old java stuff is put # Java=/share/jdk1.2.2 # where java 1.2.2 stuff is put # Java=/share/j2sdk1.3.0 # where java stuff was put # Java=/share/j2sdk1.4.1 # where java stuff is put. Thanks to James MacD. # Java=/share/j2sdk1.4.2_07 # Where Java is in JBH358 Spring 2006 Java=`ls -d /share/j2sdk*|tail -1` Lisp=/share/acl5 # Where LISP is Allegro Common Lisp Local=/share/bin # where Local executables are put (/share/bin or /usr/local/bin) AuthorBin=/u/faculty/dick/bin # where dick botting's executables are put LD_LIBRARY_PATH=/usr/lib:/usr/local/lib export LD_LIBRARY_PATH if [ $# -eq 0 -o x$1 = x ]; then echo "Usage: Q program-file-name";exit 1; fi filename=`echo "/bin/echo $1"|sh` # Needed to rectify parity! progname=`expr $filename : '\(.*\)\..*'` if expr x$progname : 'x\/' >/dev/null then runprog=$progname else runprog=./$progname fi suffix=`expr $filename : $progname'\(.*\)'` if [ "x$progname" != "x" ] && [ -r makefile -o -r Makefile ] && grep '^'$progname'.*:' [mM]akefile >/dev/null then if grep '^'$progname':' [mM]akefile >/dev/null then make $progname && $AuthorBin/ask "Run $runprog" && $runprog else if egrep "^$progname\.o:|$suffix.o:" [mM]akefile >/dev/null then make $progname.o && echo $progname is ready to be linked else firsttarget=`grep '^[^ ].*:' [Mm]akefile | sed -n "/^ *\\([^:]*\\):.*$filename.*/s//\\1/p"` if [ 'x' != "x$firsttarget" ] then echo Found "$firsttarget" in Makefiles $AuthorBin/ask "Do you want to make $firsttarget" && make $firsttarget else echo Assuming default target for make.; make fi fi fi else case "$filename" in setup) if grep -s 'map.*quickie' $HOME/.exrc>/dev/null;then echo OK else echo 'map q :w! :!'$AuthorBin/quickie' % ' >>$HOME/.exrc;echo OK fi;; cs201) if grep -s 'map.*quickie' $HOME/.exrc>/dev/null;then echo OK else echo 'map q :w! :!'$AuthorBin/quickie' % ' >>$HOME/.exrc; echo 'set number showmode nomagic' >>$HOME/.exrc; echo OK fi;; cs202) if grep -s 'map.*quickie' $HOME/.exrc>/dev/null;then echo OK else echo 'map q :w! :!'$AuthorBin/quickie' % ' >>$HOME/.exrc; echo 'set number showmode nomagic' >>$HOME/.exrc; echo OK fi;; novice) if grep -s 'map.*quickie' $HOME/.exrc>/dev/null;then echo OK else echo 'map q :w! :!'$AuthorBin/quickie' % ' >>$HOME/.exrc; echo 'set number showmode nomagic' >>$HOME/.exrc; echo OK fi;; [Bb][Bb][Ss])echo The BBS dead, sorry.;; core) echo \' core \' is the image of a program that crashed echo Here is listing as characters and in hexadecimal set -x; od -cx core|more -P"tap q to quit, SP for more" echo "Please remove \'core\'";; Q) echo \' Q is not a quickie \';; quickie) echo \' $filename is not a quickie \';; [Mm]akefile) set -x; make;; *mbox) set -x; $Mailer -f $filename;; *Mail/*) set -x; $Mailer -f $filename;; *.html) echo $filename is an Internet Hypertext file set -x; lynx $filename ;; *.htm) echo $filename is an MicroSoft Internet Hypertext file set -x; lynx $filename ;; *.java|*.jav) echo $filename is a Java Program set -x if $Java/bin/javac $filename >$filename.errors 2>&1 then set +x rm $filename.errors # echo Generating documentation for classes in $filename... # $Java/bin/javadoc -windowtitle "$progname" -nodeprecatedlist -notree -noindex -nohelp -nonavbar $filename| # $Java/bin/javadoc -1.1 -notree $filename| # tee /dev/tty | # sed -n '/^[gG]enerating \(.*\.html\)\.*/s//\1/p'| while read docname; do $AuthorBin/fix.javadoc $docname;done echo 'Select a class to run (or tap CTRL/C)': ls -tr *.class|sed 's/.class$//'| pr -4 -t echo -n "Choice: "; read classname; set -x $Java/bin/java $classname else more $filename.errors fi ;; *.class) if od -x $1|head -2|grep "^0000000 feca beba" >/dev/null #is Java then echo $filename looks like a compiled Java Class... set -x basename=`basename $filename` classdir=`expr $filename : "\(.*\)$basename"` classdir=${classdir:-.} classname=`expr $basename : '\(.*\)\.class'` # CLASSPATH=$Java:$classdir:. $Java/bin/javap $classname # $Local/ask "Interpret it" && $Java/bin/java $classname $Java/bin/java $classname else echo 'That is not a "Java" class.' fi ;; *.mdl) echo A Rational Rose Model... please run \'rose\' on Orion echo Logging into Orion... Run 'thorn' before you log out! slogin orion echo Returning to `hostname` ;; *.txt) echo \' $filename \' is a text file, you can use view to read it ;; READ*ME) echo \' $filename \' is a text file, you can use view to read it ;; *.article) echo Sorry\! But I can\'t post news for you. ;; *.letter) echo Sorry\! But I can\'t send mail for you. ;; *.lsp) echo XLISP...; $AuthorBin/lisp $filename;; *.cl) echo Allegro Common LISP in $Lisp... echo Input "(load \"$filename\")" at the "USER(1):" prompt. ; $Lisp/lisp;; *.dxl) $Lisp/lisp $filename;; libs) echo "Internet information Systems..."; set -x; $Local/libs;; *.mth) echo $filename is a MATHS file... translating to $progname.html $AuthorBin/mth2html $filename >$progname.html Q $progname.html ;; *.sml) echo Standard meta language has been disconitnued # set -x; sml $filename ;; *.smv) echo The Symbolic Model Verifier is checking your model... set -x; ~dick/bin/smv $filename ;; *.sql) echo Standard Query Language can not be handled by q/quickie # set -x; sml $filename ;; *.pdf)echo Adobe Acrobat file\! Using Adobe Acrobat Reader; set -x $Local/acroread $filename;; *.ps) echo PostScript\! echo Using Ghost Script to display file. set -x /usr/bin/gs $filename || $Local/gs $filename ;; *.gif) echo Graphic Interchange format; set -x; xeyes $filename;; *.mpeg|*.mpg) set -x; $Local/mpeg_play $filename;; *.jpeg|*.jpg) set -x; $Local/xeyes $filename;; *.o) file $filename; echo use a compiler to link and load it ;; *.dvi) set -x; xdvi $filename;; *.tex) if expr `grep -v '^%' $filename|head -1` : '\\documentclass' >/dev/null then set -x; latex $filename elif expr `grep -v '^%' $filename|head -1` : '\\documentstyle' >/dev/null then echo "documentstyle indicates an out of date LaTeX (2.09) file!" set -x; latex $filename else set -x; tex $filename fi && Q $progname.dvi;; *.scheme) echo Scheme was available on Blaze...;; *.alg) $Local/mkc $filename>$progname.c&& echo $progname.c has been created;; *.pl|*.plg) echo SWI Prolog compilation...; if $AuthorBin/pl -o $runprog -c $filename >$filename.errors 2>&1 then echo Compilation OK. cat $filename.errors; cat /dev/null>$filename.errors eval $runprog else more $filename.errors fi ;; *.pro) echo Gnu Prolog compilation...; if /usr/bin/gplc -o $runprog $filename >$filename.errors 2>&1 then echo Compilation OK. cat $filename.errors; cat /dev/null>$filename.errors eval $runprog else more $filename.errors fi ;; *.tm) $AuthorBin/tm $filename;; *.au) set -x; audiotool -p $filename;; *.st) echo SmallTalk... echo Please input \" \'$filename\' load\" at the ">" prompt; sleep 1 $Local/st;; *.image)echo The SmallTalk Image file \'$filename\' will be reloaded; set -x; $Local/st $filename ;; *.cpp) echo "$filename looks like a C++ program." if grep "#include *\"ccc_.*\.h" $filename >/dev/null then echo This looks like a 3rd edition Horstmann example. CCC=/share/ccc3e if [ -d /share/ccc3e ] then echo The libraries are in "$CCC". Scanning for files to include. files="" if grep "#include \"ccc_empl\.h" $filename >/dev/null then files="$files $CCC/ccc_empl.cpp" fi if grep "#include \"ccc_time\.h" $filename >/dev/null then files="$files $CCC/ccc_time.cpp" fi if grep "#include \"ccc_win\.h" $filename >/dev/null then files="$files $CCC/ccc_x11.cpp $CCC/ccc_shap.cpp" fi set -x if g++ -w -I$CCC -I/usr/X11R6/include -I/usr/include -L/usr/X11R6/lib -lX11 -o $progname $filename $files >$filename.errors 2>&1 then echo "Compiled, and Linked OK. Loading..." rm $filename.errors eval $runprog else more $filename.errors fi else echo Unable to find the libraries in "$CCC" fi elif grep "#include \"ccc_.*\.cpp\"" $filename >/dev/null then echo This looks like a 2nd edition Horstmann example. if [ -d /share/nec358/ccc/cccfiles ] then CCC=/share/nec358/ccc/cccfiles else echo /share/nec358/ccc/cccfiles disappeared, Sorry. exit 2 fi set -x if c++ -w -I$CCC -I/usr/X11R6/include -I/usr/include -L/usr/X11R6/lib -lX11 -o $progname $filename >$filename.errors 2>&1 then echo "Compiled, and Linked OK. Loading..." rm $filename.errors eval $runprog else more $filename.errors fi else set -x if g++ -w -I/usr/include -o $progname $filename >$filename.errors 2>&1 then echo "Compiled, and Linked OK. Loading..." rm $filename.errors eval $runprog else more $filename.errors fi fi ;; *.cc) set -x; if g++ -o $progname -O $filename -lm >$filename.errors 2>&1 then rm $filename.errors eval $runprog else more $filename.errors fi;; *.C) set -x; if g++ -o $progname -O $filename -lm >$filename.errors 2>&1 then rm $filename.errors eval $runprog else more $filename.errors fi;; # g++ -o $progname -O -s $filename -I /usr/local/lib/g++-include -L /usr/local/lib/gcc-lib/sparc-*-solaris2/2.4.5 -lm && eval $runprog;; *.c) set -x if cc -o $progname -s -O $filename -lm >$filename.errors 2>&1 then rm $filename.errors eval $runprog else more $filename.errors fi;; *.errors) echo $filename contains errors from the last compile of $progname; echo Enter ':q!' to exit ;; *.[hH])echo $filename is a header file. Enter "':q!'" to quit.;; *.scr)echo $filename is a script file. echo It has been saved. if $AuthorBin/ask "Do you want to mail this to your teacher" then echo Faculty; ls /u/faculty; echo Input one of the above. read faculty; mailx -s "Script $filename" $faculty <$filename fi echo Enter "':q!'" to quit.;; *.shar) /bin/sh <$filename;; *.sh) set -x; /bin/sh $filename;; .bash_profile) echo $filename saved. Quit editing and type ". ./$filename" to test it.;; .profile) echo $filename saved. Quit editing and type ". ./$filename" to test it.;; *.awk) set -x; awk -f $filename;; *.lex) set -x; lex $filename;; *.mm) echo Formating file...;mm $filename|more;; *.ms) echo Formating file...;nroff -ms $filename|more;; *.mn) echo Formating file...;tbl $filename|nroff -man |more;; *.man) echo Formating file...;tbl $filename|nroff -man |more;; *.sed) set -x; sed -f $filename;; *.tgz)echo A Tar Gzip file. Looking for gzip. if [ -x /bin/gzip ]; then GZ=/bin/gzip; elif [ -x /usr/bin/gzip ]; then GZ=/usr/bin/gzip elif [ -x $Local/gzip ]; then GZ=$Local/gzip else echo "Gzip not found, sorry."; exit fi export GZ set -x $GZ -d $filename && (quickie $progname&& $GZ $progname);; *.gz)echo A Gnu zipped file. Looking for gzip. if [ -x /bin/gzip ]; then GZ=/bin/gzip; elif [ -x /usr/bin/gzip ]; then GZ=/usr/bin/gzip elif [ -x $Local/gzip ]; then GZ=$Local/gzip else echo "Gzip not found, sorry."; exit fi export GZ set -x $GZ -d $filename && (quickie $progname&& $GZ $progname);; *.v) set -x; $Local/vlog $filename;; *.yy) set -x; yacc $filename && cc y.tab.c yylex.c yyerror.c -lm;; *.z) set -x; unpack $filename && (quickie $progname&& pack $progname);; *.Z) set -x; uncompress $filename && (quickie $progname&& compress $progname);; *.crypt) echo $filename needs decryption; $Local/crypt <$filename >$progname && (quickie $progname; rm -i $progname);; # *.crypt) echo $filename needs decryption; crypt <$filename >$progname && (quickie $progname; rm -i $progname);; *.tar) echo "Files are being eXtracted from $filename:"; tar xvf $filename;; *) if [ -d $filename ] then echo $filename is a directory:; ls -F $filename elif [ -d classes -a -r classes/$filename.class ] # Java Class then CLASSPATH=$Java/classes:classes java $filename else line1=`sed 1q $filename` if expr "$line1" : ': '>/dev/null then /bin/sh $filename elif expr "$line1" : '#!'>/dev/null then interp=`expr "$line1" : '#!\(.*\)'` echo Interpreter: $interp sed 1d $filename|$interp else echo Quickie: $filename was saved... echo Quickie: Don\'t know how to interpret this file. if expr "$filename" : '/tmp/' >/dev/null then echo "$filename is a temporary file!" else echo Hint: Put C++ programs in files with names that end .cpp echo $0 $@ |$Mailer -s "QQQ$suffix" dick@csci.csusb.edu fi exit 1 fi fi esac fi