thad@public.BTR.COM (Thaddeus P. Floryan) (02/19/91)
jon@jonlab.UUCP (Jon H. LaBadie) in <921@jonlab.UUCP> writes, and many other have followed up, regarding some tricks using the STORE's ksh for the 3B1. Let me share some of my "tricks" for the "06/03/86" (KSH+IN.Z) version. And note that the stuff in "THE KORN SHELL" book also documents the "06/03/86" version but NOT the 1.2 or 1.9 versions accompanying the various fixdisks. First, some extracts from my $HOME/.profile: ENV=$HOME/.kshrc PATH=/bin:/usr/bin:/usr/local/bin:/etc SHELL=/bin/ksh export ENV PATH SHELL set -o ignoreeof [...] From my $HOME/.kshrc: set -ao gmacs ttyname=$(tty) HISTFILE=$HOME/.kshist-${ttyname##*/};export HISTFILE HISTSIZE=128;export HISTSIZE MORE=-c PATH=$PATH PS1=`/usr/local/bin/kshpr` PS2="ksh +> " PS3=":> " EDITOR=/usr/local/bin/emacs FCEDIT=/usr/local/bin/emacs VISUAL=/usr/local/bin/emacs alias ll="ls -l" The "set -o ignoreeof" is VERY important; prevents an itchy finger typing too many ^D logging one off; with that option set, one must "exit" to logoff, and the ^D still works fine for lower-level shell invocations ONLY when it is in the .profile which is read only by the top-level ksh. The "HISTFILE" was needed since I'm usually logged on serial port(s), ptys, and at the console simultaneously; the "trick" creates uniquely-named files based on the "line" over which one is logged in. "root" on my systems also has "/bin/ksh" as its shell, and that works fine, even "su'd" (nice, because if I type a command that requires root privs, I just "su" then recall the original command). That "kshpr" prompt program is so simple I've enclosed it at the end of this posting. Only two things have caused some grief using ksh, and the workaround is easy: 1) uucp requests using "~" need to be started from sh unless you really want your home directory path substituted. What I usually do is have my uucp requests in a file (for record-keeping purposes) then simply do: sh file A typical file (in my ~/uucp/work) looks like: uucp -m osu-cis!~/GNU.how-to-get ~/osu-cis/ uucp -m osu-cis!~/ls-lR.Z ~/osu-cis/ echo "#\n#\t`date`\n#" >> files.osu-cis echo "uucp -m osu-cis!~/GNU.how-to-get ~/osu-cis/" >> files.osu-cis echo "uucp -m osu-cis!~/ls-lR.Z ~/osu-cis/" >> files.osu-cis 2) some items in crontab had to be qualified. For example (note /bin/sh): #sccs "@(#)fndcmd:crontab 1.7" # #Mn Hr Da Mo Da (0=SUN, 1=MON, 2=TUE, 3=WED, 4=THU, 5=FRI, 6=SAT) #of of of of of #Hr Da Mo Yr Wk Command # 16,46 * * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.poll >/dev/null" 18,48 * * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" 00 4 * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.admin >/dev/null" 59 23 * * * /bin/sh -c "/usr/local/bin/hdwarn.day >/dev/null" 59 23 * * * /bin/sh -c "/usr/local/bin/du-logs.day >/dev/null" 03 3 * * 0 /bin/sh -c "/etc/clockupd.wk >/dev/null" 30 5 * * 1 /bin/su uucpadm -c "/usr/lib/uucp/uudemon.cleanu >/dev/null" 30 5 * * 1 /bin/sh -c "/etc/cleanup.wk >/dev/null" Thad Floryan [ thad@btr.com (OR) {decwrl, mips, fernwood}!btr!thad ] -------------------- begin included material ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 02/19/1991 09:56 UTC by thad@thadlabs # Source directory /usr/local/src/kshpr # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 455 -rw-r--r-- Makefile # 719 -rw-r--r-- kshpr.c # if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= Makefile ============== if test -f 'Makefile' -a X"$1" != X"-c"; then echo 'x - skipping Makefile (File already exists)' else echo 'x - extracting Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && X# System V (3B1) makefile for kshpr X# XCC = gcc XCFLAGS = -O XLDFLAGS = -s XLIBS = /lib/crt0s.o /lib/shlib.ifile XNAME = kshpr XOBJS = kshpr.o XSRCS = kshpr.c XDEST = /usr/local/bin XOWNER = thad XGROUP = users XFMODE = 555 X X$(NAME) : $(OBJS) X $(LD) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS) X Xinstall : $(NAME) X mv $(NAME) $(DEST)/ X chown $(OWNER) $(DEST)/$(NAME) X chgrp $(GROUP) $(DEST)/$(NAME) X chmod $(FMODE) $(DEST)/$(NAME) X Xclean : X rm -f *~ $(OBJS) core SHAR_EOF $TOUCH -am 0930231490 'Makefile' && chmod 0644 Makefile || echo 'restore of Makefile failed' Wc_c="`wc -c < 'Makefile'`" test 455 -eq "$Wc_c" || echo 'Makefile: original size 455, current size' "$Wc_c" fi # ============= kshpr.c ============== if test -f 'kshpr.c' -a X"$1" != X"-c"; then echo 'x - skipping kshpr.c (File already exists)' else echo 'x - extracting kshpr.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'kshpr.c' && X/* kshpr X * X * This program displays my idea of a ksh prompt that is different for a X * normal user than it is for a su'd user. X * returns a "false" status. X * X * The intent is for this program to be run in a .kshrc script per: X * X * PS1=`/usr/local/bin/kshpr` X * X * The normal output is: "nodename ksh $PPID/$$> ", and X * the output if su'd is: "nodename ksh-su $PPID/$$# " X * X * Thad Floryan, 3-June-1989 X * Updated 30-Sep-90 to include nodename X */ X X#include <stdio.h> X#include <sys/utsname.h> X Xextern int getuid(), uname(); X Xmain() X{ X struct utsname name; X uname(&name); X if (getuid() == 0) X fprintf(stdout, "%s ksh-su $PPID/$$# ", name.nodename); X else fprintf(stdout, "%s ksh $PPID/$$> ", name.nodename); X} SHAR_EOF $TOUCH -am 0930232990 'kshpr.c' && chmod 0644 kshpr.c || echo 'restore of kshpr.c failed' Wc_c="`wc -c < 'kshpr.c'`" test 719 -eq "$Wc_c" || echo 'kshpr.c: original size 719, current size' "$Wc_c" fi exit 0