Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!uwvax!rutgers!sri-spam!mordor!lll-tis!lll-lcc!ptsfa!ihnp4!cuae2!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: comp.unix.wizards Subject: Re: #! magic number Message-ID: <1792@ttrdc.UUCP> Date: Tue, 30-Jun-87 19:04:54 EDT Article-I.D.: ttrdc.1792 Posted: Tue Jun 30 19:04:54 1987 Date-Received: Thu, 2-Jul-87 03:33:31 EDT References: > <2211@bunker.UUCP> <1097@mtune.ATT.COM> <488@quacky.UUCP> Organization: AT&T, Skokie, IL Lines: 63 Summary: don't be silly In article <488@quacky.UUCP>, dce@mips.UUCP (David Elliott) writes: < In article <1788@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: < >In article <7180@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: < >< And indeed, it does more: < >< % egrep uucp:: /etc/passwd < >< uucp::16:16:UNIX-to-UNIX Copy:/usr/spool/uucppublic:/usr/lib/uucp/recording < >< % cat /usr/lib/uucp/recording < >< #! /bin/awk NR > 1 { print } < >< [message] < >This is like using a cannon to kill a gopher. < >Why not < > < >/bin/cat << ! < > [message] < >! < >which will also work on systems other than "Berserkeley" UNIX. < What? You mean that your /etc/password will allow you to put multiple < lines in the shell field? What you suggest is that < uucp::16:..:/bin/cat << ! < [message] < is a valid entry in the password file. No, no, that's not what I meant. I meant to use a script containing that text. < The point was that with #! you can use shell scripts or any other < scripts as login shells or anywhere an executable program can go. I looked at the source for /bin/login on a SVR2 machine (3B20). It uses execlp() to execute the login shell, so it can be a shell script. (This is probably a moot point anyhow since System V doesn't interpret "#!".) < ...but you could not simply say < < /bin/cat << ! < [message] < ! < < and have it work unless login(1) executes the script vi sh. I also tested a script containing just /bin/cat << ! [message] ! as a "login shell" upon a real live BSD 4.2 machine. Surprise, surprise, it worked just dandy. I also tried putting in a "ps -axww" and it showed the script being executed by /bin/sh. I tend to doubt that the machine I performed this test upon is nonstandard in that respect. < The fact that #!/bin/awk or #!/bin/sed or #!/usr/ucb/tail +2 will < work is due to the generality of the #!, and generality is a big < win. < -- < David Elliott {decvax,ucbvax,ihnp4}!decwrl!mips!dce In some cases this IS nice. But in the example given, it was still like using a cannon to kill a gopher. -- |------------dan levy------------| Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, | an engihacker @ | vax135}!ttrdc!ttrda!levy | at&t data systems division | Disclaimer: try datclaimer. |--------skokie, illinois--------|