Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!adm!news From: postmaster@CCF.NRL.NAVY.MIL (SMTP MAILER) Newsgroups: comp.unix.wizards Subject: Mail not delivered yet, still trying Message-ID: <22058@adm.BRL.MIL> Date: 11 Jan 90 23:17:15 GMT Sender: news@adm.BRL.MIL Lines: 696 ----Mail status follows---- Have been unable to send your mail to , will keep trying for a total of three days. At that time your mail will be returned. ----Transcript of message follows---- Date: 11 Jan 90 09:26:00 EST From: unix-wizards@BRL.MIL Subject: UNIX-WIZARDS Digest V9#042 To: "whitis" Return-Path: <@nrl3.arpa:unix-wizards-request@sem.brl.mil> Received: from nrl3.arpa by nrl3.arpa with SMTP ; Thu, 11 Jan 90 09:24:58 EST Received: from SEM.BRL.MIL by nrl3.arpa with SMTP ; Tue, 9 Jan 90 03:27:57 EST Received: from SEM.BRL.MIL by SEM.brl.MIL id aa21640; 9 Jan 90 3:01 EST Received: from sem.brl.mil by SEM.BRL.MIL id aa21575; 9 Jan 90 2:45 EST Date: Tue, 09 Jan 90 02:45:18 EST From: The Moderator (Mike Muuss) To: UNIX-WIZARDS@BRL.MIL Reply-To: UNIX-WIZARDS@BRL.MIL Subject: UNIX-WIZARDS Digest V9#042 Message-ID: <9001090245.aa21575@SEM.BRL.MIL> UNIX-WIZARDS Digest Tue, 09 Jan 1990 V9#042 Today's Topics: Re: Access to UNIX-Related Publications Re: AWK/shell quoting (was: Re: Access to UNIX-Related Publications) Sun4/SUNOS4.0.1 and tcsh Re: fcntl/socket anomaly Re: Mach and faulting in the file (Re: GNU Emacs, memory usage, releasing) How to create a restricted shell Re: How to create a restricted shell Re: GNU Emacs, memory usage, releasing How to delete a file with ^? chars in the name? Need a Tape Drive Hardware guru Re: fuzzy strcmp Re: PWD in Bourne Shell PS1 ----------------------------------------------------------------- From: Sun Visualization Products Subject: Re: Access to UNIX-Related Publications Date: 7 Jan 90 18:39:55 GMT To: unix-wizards@sem.brl.mil In article <166@omaha1.UUCP> wcc@omaha1.UUCP (William C Carey) writes: > >Any of the luminaries out there know how to get 'awk' (not nawk) to ouput a >single-quote character ( ascii 0x27 ). I can't get the 'print' or > Here's an example that should get you in the right direction: awk 'BEGIN { SQ = sprintf("%c", 39); DQ = sprintf("%c", 34); } { printf("%cHow is this?%c\n", DQ, DQ); printf("%cAnd this?%c\n", SQ, SQ); } -- Matthew Lee Stier | Sun Microsystems --- RTP, NC 27709-3447 | "Wisconsin Escapee" uucp: sun!mstier or mcnc!rti!sunpix!matthew | phone: (919) 469-8300 fax: (919) 460-8355 | ----------------------------- From: Paul Lew Subject: Re: AWK/shell quoting (was: Re: Access to UNIX-Related Publications) Date: 7 Jan 90 21:02:40 GMT To: unix-wizards@sem.brl.mil >In article <166@omaha1.UUCP> wcc@omaha1.UUCP (William C Carey) writes: >Any of the luminaries out there know how to get 'awk' (not nawk) to ouput a >single-quote character ( ascii 0x27 ). I can't get the 'print' or >the 'printf' statement to do it with any combination of backslashes, >double-quotes, or percent characters. Try avoid using quotes, double-quotes will make life a lot easier. I use the following: BEGIN { q = 39; } { printf "this is a quote: %c\n", q; } this free you up to worry about what you want to do instead of quoting problem. Just remember the decimal value for quote is 39, I did not start using this method until I memorized its value (the most intuitive reaction a programmer has at that point is to use "quote" mostly because he can not remember the decimal value for quote and dont feel like look into the ASCII table for it!) -- Paul Lew (lew@gsg.gsg.com) UUCP: oliveb---+ uunet---samsung--+ General Systems Group, 5 Manor Parkway harvard--+--gsg--lew Salem, NH 03079 (603) 893-1000 decvax---+ ----------------------------- From: Jussi Eloranta Subject: Sun4/SUNOS4.0.1 and tcsh Date: 8 Jan 90 07:59:18 GMT To: unix-wizards@sem.brl.mil I recall some discussion about tcsh problems with pipes.. but I was unable to find the fixed version of tcsh for sun4/sunos4.0.1 (or does it exist at all?) Thanks, Jussi -- ============================================================================ Jussi Eloranta Internet(/Bitnet): University of Jyvaskyla, eloranta@tukki.jyu.fi Finland [128.214.7.5] ----------------------------- From: Chris Torek Subject: Re: fcntl/socket anomaly Keywords: obscure behavior Date: 8 Jan 90 08:27:10 GMT To: unix-wizards@sem.brl.mil >In article <10763@encore.Encore.COM> peralta@encore.com (Rick Peralta) writes: >>Why when setting the F_SETOWN on a socket a pfind is not done on the PID? >>Maybe more to the point, why the double standard on how a pgrp is specified? 4.3-tahoe does a pfind, but not for pgroups (negative values), only for pids (positive values), and only when translating to TIOCSPGRP (more below). In article <129970@sun.Eng.Sun.COM> lm@snafu.Sun.COM (Larry McVoy) writes: >F_SETOWN has been a botch from day one as far as I'm concerned. For >those who don't know (or don't remember) F_SETOWN is used to say "send >this pid the SIGIO when the time is right". The documentation has >always said that you can specify pgrps instead of pids (one of them was >negative to indicate the type) and SunOS, at least, never did that >(stay tuned). Actually, I am fairly sure that SunOS 3.x had the 4.2BSD bug where pid and pgroup were reversed (between documentation and code). Whether that has been fixed, I do not know. (The SunOS 4.x code is substantially different, and I have not read it.) >Furthermore, the F_SETOWN uses the same field in the tty >structure that the tty sub system uses for job control (where ^Z and >others get sent). So if you use F_SETOWN on an active tty you get very >strange things happening. (The following applies only to 4.3BSD and otherwise-unchanged derivatives thereof.) F_SETOWN on an inode translates into a TIOCSPGRP ioctl, so that whatever checks are applied to TIOCSPGRP are applied to fcntl(ttyf, F_SETOWN). The translation goes like this: if (value > 0) { [value is a pid, not a pgroup] struct proc *p = pfind(value); if (p == 0) return (ESRCH); value = p->p_pgrp; } else [value is a negated pgroup ID] value = -value; return (fioctl(fp, (int)TIOCSPGRP, (caddr_t)&value); For a socket, it sets ((struct socket *)fp->f_data)->so_pgrp to the given value. Tty pgroups are stored in tp->t_pgrp: a different place. >My guess is that the SIGIO interface was a hack that some grad student >needed. Not really. It does seem to be done rather badly, however. >They hacked it in, it works in the obvious cases, it's stuck >around. It needs a rewack to be clean (I just checked SunOS - we do >absolutely no permissions checks on F_SETOWN on sockets). They are unnecessary. SIGIO is a completely benign signal. If a process is not catching it, SIGIO is discarded. If a process *is* catching it, that process is required to figure out why the SIGIO occurred and whether it still has any reason to do anything about it, so extra SIGIO signals merely reduce efficiency. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris ----------------------------- From: "Steven M. Schultz" Subject: Re: fcntl/socket anomaly Keywords: obscure behavior Date: 8 Jan 90 09:11:26 GMT Sender: news@wlbr.imsd.contel.com To: unix-wizards@sem.brl.mil In article <129970@sun.Eng.Sun.COM> lm@sun.UUCP (Larry McVoy) writes: >In article <10763@encore.Encore.COM> peralta@encore.com (Rick Peralta) writes: >> >>Why when setting the F_SETOWN on a socket a pfind is not done on the PID? >>Maybe more to the point, why the double standard on how a pgrp is specified? > >F_SETOWN has been a botch from day one as far as I'm concerned. For amen. >those who don't know (or don't remember) F_SETOWN is used to say "send >this pid the SIGIO when the time is right"... >Furthermore, the F_SETOWN uses the same field in the tty >structure that the tty sub system uses for job control... >My guess is that the SIGIO interface was a hack that some grad student >needed. They hacked it in, it works in the obvious cases, it's stuck >around... The hack/botch is the F_SETOWN, or rather the whole fcntl(2) syscall. As i recall fcntl(2) was (needlessly?) instituted by the creators of System V(anilla) and adopted by Berkeley as a compatability measure, nothing that really couldn't be done by ioctl(2) but a new syscall was created anyhow. and don't forget the overlaying (reuse) of the VTIME and VEOT members of the AT&G Unix tty system - switch modes from to/from 'cbreak' and you have surprises too. but then, i suppose it was done by a graduate student... .5;-) Steven ----------------------------- From: Larry McVoy Subject: Re: fcntl/socket anomaly Keywords: obscure behavior Date: 8 Jan 90 18:29:08 GMT Sender: news@sun.eng.sun.com To: unix-wizards@sem.brl.mil In article <21691@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: >F_SETOWN on an inode translates into a TIOCSPGRP ioctl, so that whatever >checks are applied to TIOCSPGRP are applied to fcntl(ttyf, F_SETOWN). >The translation goes like this: > > if (value > 0) { [value is a pid, not a pgroup] > struct proc *p = pfind(value); > if (p == 0) > return (ESRCH); > value = p->p_pgrp; > } else [value is a negated pgroup ID] > value = -value; > return (fioctl(fp, (int)TIOCSPGRP, (caddr_t)&value); Those checks are inappropriate for the F_SETOWN. For example, POSIX insists that the tty in question be your controlling tty. That's both unecessary and unlikely for processes wanting SIGIO on a tty. >>My guess is that the SIGIO interface was a hack that some grad student >>needed. > >Not really. It does seem to be done rather badly, however. > >>They hacked it in, it works in the obvious cases, it's stuck >>around. It needs a rewack to be clean (I just checked SunOS - we do >>absolutely no permissions checks on F_SETOWN on sockets). > >They are unnecessary. SIGIO is a completely benign signal. If a >process is not catching it, SIGIO is discarded. If a process *is* >catching it, that process is required to figure out why the SIGIO occurred >and whether it still has any reason to do anything about it, so extra >SIGIO signals merely reduce efficiency. Permission checks are rarely "unnecessary", it's much more likely that they're either missing or incorrect. In this case, they're missing. Suppose I have process A and process B. A does a F_SETOWN on some socket and then goes on, expecting a SIGIO at some later time. B comes along, and also does a F_SETOWN on the same socket. A has been robbed. To head off a needless discussion: yes, I realize that if you do the "right thing" everything is OK and there is no need for permission checks. My claim is that the number of programmers who "do the right thing" (sorry spike) are getting fewer and fewer. --- What I say is my opinion. I am not paid to speak for Sun, I'm paid to hack. Larry McVoy, Sun Microsystems (415) 336-7627 ...!sun!lm or lm@sun.com ----------------------------- From: Peter da Silva Subject: Re: Mach and faulting in the file (Re: GNU Emacs, memory usage, releasing) Date: 8 Jan 90 15:05:53 GMT To: unix-wizards@sem.brl.mil > What I mean here is that you can allocate your block poimters, then call > map_fd to map the file into memory. > The problem is that unless you copy the file on disk you can't back > out of your edits at the last moment (:q! for vi people). If you're > going to copy the file you might as well copy it into vmem. You misunderstand. I wasn't suggesting making direct edits on the memory image. On the contrary, you map it in read-only if you can. What I was suggesting was that since most of the things you're doing to the file don't involve modifying it, you might as well page it in from disk when you need it, only coping it to writable memory when you want to modify it. For example, suppose you want to do a search and replace. You fault in all the pages from here to the replacement location, copy the block that contains the replacement into two new blocks (using the block-splitting method) and add the new text. The blocks you just read can be discarded when needed by the memory manager, rather than having to be written out to the paging area, saving considerable disk access. Only modified blocks would need to be written. -- _--_|\ Peter da Silva. +1 713 274 5180. . / \ Also or \_.--._/ v "Have you hugged your wolf today?" `-_-' ----------------------------- From: Tzu-Hsi Pan Subject: How to create a restricted shell Keywords: restricted shell Date: 8 Jan 90 16:19:51 GMT Sender: usenet@cps3xx.uucp To: unix-wizards@sem.brl.mil Could someone tell me how to build up a restricted shell for some user such that only a couple of commands can be executed under a new root environment? Thanks. -Pan (pantz@mth.msu.edu) ----------------------------- From: Wm E Davidsen Jr Subject: Re: How to create a restricted shell Keywords: restricted shell Date: 8 Jan 90 20:05:48 GMT To: unix-wizards@sem.brl.mil In article <5946@cps3xx.UUCP> pantz@mth.msu.edu (Tzu-Hsi Pan) writes: | | Could someone tell me how to build up a restricted shell for some user | such that only a couple of commands can be executed under a new root | environment? Thanks. rsh works with /bin/sh and ksh. You can either execute the rsh command (SysV) or execute the shell with the -r flag. You simply set the PATH to point to a directory containing only the things you want to allow, and then (assuming a recent shell) set the PATH variable readonly. I usually create a /usr/rbin directory and link stuff in from /bin and /usr/bin. Ex: PATH=/usr/rbin readonly PATH; export PATH -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon ----------------------------- From: Craig Finseth Subject: Re: GNU Emacs, memory usage, releasing Keywords: GNU emacs malloc memory working set gap editor Date: 8 Jan 90 16:43:41 GMT Sender: news@uc.msc.umn.edu To: unix-wizards@sem.brl.mil In article peter@ficc.uu.net (Peter da Silva) writes: >There seems to be an assumption here that the only possible methods are >buffer gap and a linked list of lines. What about a linked list of larger >blocks? ... Think of pure buffer gap and linked line as opposite ends of a continuum. (Technically, linked character would be on the one end, but I will ignore that case.) Pure buffer gap has one chunk, which is the entire object. As you divide it into separate chunks (paged buffer gap), the number increases and their size decreases. Eventually, you get to a chunk size of one line and have linked line. In may of the intermediate cases, whether you use an array or linked list is an implementation detail. Craig A. Finseth fin@msc.umn.edu [CAF13] Minnesota Supercomputer Center, Inc. +1 612 624 3375 ----------------------------- From: Craig Finseth Subject: Re: GNU Emacs, memory usage, releasing Keywords: GNU emacs malloc memory working set gap editor Date: 8 Jan 90 16:48:15 GMT Sender: news@uc.msc.umn.edu To: unix-wizards@sem.brl.mil In article peter@ficc.uu.net (Peter da Silva) writes: >> I contend that in a "modern workstation environment" (e.g., Sun 3/60), >> a simple buffer gap method is preferred over both paged buffer gap and >> linked line. I leave it as an excercise for the reader to figure out >> why. >I'm not sure this is a valid conclusion. If 75K is the optimal file size >for a buffer-gap solution, how about paged buffer-gap with 75K pages? Or >to add a bit of compromise with some of today's brain-dead architectures >perhaps 64K pages would work nearly as well. Where did this "75K" figure come from? It wasn't mentioned by me. It would be a very unusual constant to remain constant over a wide range of architectures, speeds, memory sizes, and other performance-related figures. In particular, I have had no trouble editing multi-megabyte files in GNU Emacs on a Sun 3/280 w/8 MBytes of memory. Craig A. Finseth fin@msc.umn.edu [CAF13] Minnesota Supercomputer Center, Inc. +1 612 624 3375 ----------------------------- From: Joe Weening Subject: Re: GNU Emacs, memory usage, releasing Date: 8 Jan 90 21:56:27 GMT Sender: USENET News System Followup-To: comp.editors To: unix-wizards@sem.brl.mil I'm posting this message to help RMS's desire to remove the discussion of editor implementation methods from gnu.emacs. The discussion is currently going on in comp.editors, gnu.emacs and comp.unix.wizards. Therefore not everyone contributing to the discussion may have seen RMS's messages. The discussion is appropriate for comp.editors, so that's where I'm directing followups to this message. It is not appropriate for gnu.emacs, since that group is meant for short announcements only. It is not at all appropriate for comp.unix.wizards and should never have been posted there. Please, everyone, let's move this discussion to comp.editors only. If you want to continue reading it, subscribe to that newsgroup. -- Joe Weening Computer Science Dept. weening@Gang-of-Four.Stanford.EDU Stanford University ----------------------------- From: Ron Ueberschaer x4399 Subject: How to delete a file with ^? chars in the name? Date: 8 Jan 90 16:53:11 GMT Sender: news@unix.sri.com To: unix-wizards@sem.brl.mil I have a file which is named ^?^?^?H01.b (delete character?) and can't find a way to delete it. An ls -s on the directory produces: .. ... (other files) 1 ???H01.b If I do an ls *.b, it lists the other .b files, but complains: H01.b not found I've tried: rm -i * (to selectively delete everything) rm "???H01.b" rm "^v^?^v^?^v^?H01.b" (control-v delete ...) and nothing seems to work. Help me, o wizards! --Ron Ueberschaer ubi@unix.sri.com ...!{hplabs,rutgers}!sri-unix!ubi ----------------------------- From: Ira Rampil Subject: Need a Tape Drive Hardware guru Keywords: Tape, guru, $$$$ Date: 8 Jan 90 21:12:36 GMT To: unix-wizards@sem.brl.mil It was a classic story. A friend was using a kennedy clone streaming tape on a PDP-11 to record lab data. The original drive 'disappeared' and now he needs to read his old tapes. He has another Kennedy drive but it can not read most of the tapes - we hypothesize a relative head misalginment. Is there anyone out there with the requisite skill to retrieve the data. It is worth BIG bucks to my colleague! Any clues, hints or vectors would be much appreciated! Thanks, Ira Rampil, MSEE, MD Dept of Anesthesia Univ. Cal, San Francisco (415) 476-9037, or rampil@cca.ucsf.edu ----------------------------- From: Fred Mitchell - PA Subject: Re: fuzzy strcmp Date: 8 Jan 90 22:30:42 GMT To: unix-wizards@sem.brl.mil In article <297@hhb.UUCP> istvan@hhb.UUCP (Istvan Mohos) writes: >tchrist@convexe.uucp (Tom Christiansen @ Convex Computer) writes: >>I'm looking for an algorithm that would allow me to determine >>whether two strings were similar. Thus >> >> "abcde" !~ "xyzzy" >> "this old man can read" =~ "that old man can't read" >> >>... perhaps just >> float strfzcmp(string1,string2) I will give a general description of an algorithm that can accomplish what you ask. NOTE: I am doing this from the 'top of my head'. Some refinement may be in order. You will do a weighted comparision based on two factors: a) The number of characters each string has in common b) The number of matches the strings have in sequence Let's take two arbitrary strings: "This old man can't read" string alpha "That silly man can't read" string beta Notice that they are of different lengths. Also, there is an alignment shift. The following algorithm _should_ properly handle this: a) Count the number of occurences of each character in each string. Compare the count of each character in alpha to that in beta in the following way: For each different character from alpha & beta: Normalize the counts so that the greater is normalized to 1. Multiply the two normalized values toghether. Add this product to a running total. Normalize this total by the the length of the longest string Multiply that by weight w1 yeilding (we shall call it) yw1 b) Compare the two strings byte for byte as follows: Start at the beginning of alpha & beta (let's use i and j as indexes) initialize k to 0 Until we hit the end of either string: if (alpha[i] == beta[j]) ++k, ++i, ++j else we scan forward on beta to find a byte that matchess our current location on alpha. If so, adjust j to index it. If nothing was found, do vice-versa for alpha. When the above loop is completed, Normalize k against the size of the longest string and multiply it by weight w2 yeilding (we shall call it) yw2. return (yw1 + yw2) / (w1 + w2) This should produce a good evaluation of how closely matched alpha is to beta, taking into account mis-alignment. The value returned will be between 0 and 1 inclusive. Weight w1 should be less than w2. Perhaps w1 = w2 / 3. Experiment. As I said, this is off the top of my head, so some refinement is in order, as should be evident during the implementation/testing phase. If anyone knows of a better way to accomplish this, let's hear it! -Mitchell mitchell@cbmvax.UUCP "The shortening of the Way." ----------------------------- From: Dan Mercer Subject: Re: PWD in Bourne Shell PS1 Date: 8 Jan 90 23:12:54 GMT Keywords: To: unix-wizards@sem.brl.mil In article <18@choreo.COM> chris@choreo.UUCP (Chris Hare / System Manager) writes: :In article <8790.259b3142@ecs.umass.edu> Satam writes, :> Inserting the following three aliases will help achieve the same :> effect. Note that this is only for csh. :> ------------------------------------------------------------ :> alias cd 'chdir \!* && set prompt="${cwd:t}_\\!% "' :> alias pushd 'pushd \!* && set prompt="${cwd:t}_\\!% "' :> alias popd 'popd \!* && set prompt="${cwd:t}_\\!% "' :> ------------------------------------------------------------- : :This is quite true. However, a similar thing can be implemented in the :Bourne shell using shell functions. There are however two caveats : : : 1. We cannot use the name of a built in shell command : 2. We must recaculate the PS1 each time we do a cd. : :Firstly, becase we want the PS1 to be updated whenever we change :directories, we cannot use the builtin 'cd' command, but something like it. :We must also remember to use the new command, because using a cd will mean :that the directory reflected in our PS1 will be incorrect. : :You can try this Bourne shell function : : : go() : { : if [ "$1" ] # if we got an argument : then : cd $1 : else # otherwise go home : cd $HOME : fi : PS1=`pwd`"> " # change the PS1 : } : For what it's worth, here is how I implemented things (from file /usr/acct/ME/bin/.functs which I invoke as . .functs in my .profile) # # This file invokes function definitions # # ps3="`cat /etc/NODENAME`/`basename \`tty\``> " # set in .profile pd() { RT=$PWD; cd $1; PWD=`pwd`; PS1="$PWD ${ps3}"; } lpd() { pd $1; ls; } rt() { pd $RT; } pd (path directory) changes my directory and reflects the current directory as the first line of my two line prompt. The second line tells me what system I am on (I have access to several) and what line (I also have a variety of ways to tie in - modem, direct line, pass thru line, Token Ring). If I am in a sub shell, a /n is appended to the line number to indicate depth, since I'm frequently nested through some intermediary program or other. I can toggle between two directories with the rt command, very useful wehn transferring files (mv pattern $RT). :Remember, shell functions are not passed to their subshells. : But are accessible by shell scripts called by current shell. If you are lucky enough to have an NCR Tower (no flames please, they are my employers) they have the delightful .shrc feature implemented that gets invoked when you fork an interactive shell. Once I found that gem (by accident - it's not documented) I was able to invoke my function definitions on all shell levels. I have lots of other shifty functions. vi (no args) for instance, edits my last edited file rather than a file with no name. Very useful when mucking with balky items like makefiles. :Chris Hare Choreo Systems Inc. :Coordinator, Systems Management 150 Laurier Ave West :Authorized SCO Instructor Ottawa, Canada : Phone 613-238-1050 : Fax 613-238-4453 :*** It Works for ME ! *** email : uunet!choreo!chris -- Dan Mercer Reply-To: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) ----------------------------- End of UNIX-WIZARDS Digest **************************