HDTenEightyP/NetNews huggingface dataset:
From: csdgwh@sn370.utica.ge.com (Glenn W. Hoffman)
Newsgroups: comp.unix.shell
Subject: Re: Extracting regular expressions using egrep/
Date: 5 Jan 93 19:56:47 GMT
Organization: GE Corporate R&D Center

In article 28405@infolog.se, mich@lin.infolog.se (Thomas Michanek) writes:
> 
> I have two questions concerning csh programming:
> 
> 1. Let's say I have a variable $var containing >1 words of text.
>    I want to know if this variable contains a specific pattern in the
>    form of a regular expression.
> ...
>    Is there an easier and/or faster way to do this test? (in csh please!)
>
  egrep -s 
works silently, i.e., returns only a status that you may test in the
if command. I am not a csh programmer, but it appears that you could say
  if (echo $var | egrep -s '<regexp>') then ...

> 
> 2. Now that I know the variable contains what I want, I want to extract
>    the part(s) of the variable value that matches the regular expression.
>    Let's say I'm looking for integers (i.e. [0-9]+) and $var contains:
> 
>      Is 54 greater than 33?
> 
I would use a fragment like the following in this case:
eval `echo $var | sed -n \
	-e 's/.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*/set VAR1=\1;set VAR2=\2/p'`

The two numbers you want will be in variables VAR1 and VAX2.

No guarantees, of course, that this untested code is 100% correct, but it was
derived from a working (sh) procedure.

> 
> Any pointers are much appreciated!
> 
You're welcome. Hope this helps.

Glenn
From: bgitv@termo.unit.no (Bard Grimsmo)
Newsgroups: comp.unix.shell
Subject: Re: BASH info wanted
Keywords: BASH
Date: 9 Jan 93 07:02:03 GMT
Organization: SINTEF, The Norwegian Institute of Technology

In article <6681@pdxgate.UUCP> henk@rigel.cs.pdx.edu (David C. Henkemeyer) writes:
>I recently converted from csh to BASH, and I was looking for some good sources
>of information (besides the man page, which I have) for getting me going in my
>ne shell...  I'd appreciate any suggestions, or an FAQ file if one exists...
>
I dont think you will find any (If you do please mail it to me!). Bash
is very close to ksh (Korn Shell) and sh, and you will find all you need in
books about ksh. The differences you will find in the Bash man pages.

Bard
-- 
Bard Grimsmo     |Mail: SINTEF/Varmeteknikk         |Home: Schives Gate 7
Dr.Ing           |      7034 Trondheim, Norway      |      N-7030 Trondheim
Research Engineer|Phone: +47 7 592505               |      Norway
SINTEF Division  |Fax:   +47 7 944513               |Home phone: +47 7 523801
Termodynamics    |E-mail: Bard.Grimsmo@termo.unit.no|-rn-rn-rn-rn-rn-rn-rn-rn
Newsgroups: comp.unix.shell,comp.unix.programmer
From: boyd@prl.dec.com (Boyd Roberts)
Subject: Re: A quoting problem.
Keywords: SVR4, Bourne shell, quoting filenames.
Organization: Digital Equipment Corporation - Paris Research Laboratory
Date: Tue, 5 Jan 1993 22:05:41 GMT

In article <lkh5trINNvf@exodus.Eng.Sun.COM>, richb@stard.Eng.Sun.COM (Rich Burridge) writes:
> I need to set an environment variable called FILES to a set of such filenames,
> export it, and then run a UNIX command from within a C program. Not handling
> the quoting, this would look something like:
> 
> char cmd[1024] ;
> 
> strcpy(cmd, "FILES='file file1 file2';export FILES;rm $FILES") ;
> 

Rich, do you really need to do set an environment variable to do this
particular operation?  If you don't then it's trivial to build a sh -c
style command that goes:

    cmd quoted-args

using single quotes.

> execl("/bin/sh", "sh", "-c", cmd, (char *) 0) ;
> 
> ...

Modulo this '87 Chorey-les-Beaune (Les Beaumonts) the algorithm to quote is:

   put down '

   while we have chars
   do
       put down char

       if char == '
           put down \'
           put down '
   dood

   put down '

Then you have a string with multiple quoted arguments.


Boyd Roberts			boyd@prl.dec.com

``Not only is UNIX dead, it's starting to smell really bad.''  -- Rob Pike
From: pm0@bale.cis.ufl.edu (Patrick Martin)
Newsgroups: comp.unix.shell
Subject: Curses like menu in a bourne shell script
Date: 6 Jan 93 23:52:45 GMT
Organization: Univ. of Florida CIS Dept.

I wish to create a bourne shell menu which will read the cursor
keys and scroll a highlighted bar across a list of menu items.
I wish for return on a menu item to select that menu item.

Sounds alot like curses I know.

I dont want the solution to be entirely bourne shell (ie: I do
not wish to write a supporting C routine to perform any subtasks).
I also do not wish to have to write a termcap.

Is this possible or is it too much to ask of bourne shell?

Thanks (I hope) in advance,

Pat
Newsgroups: comp.unix.shell
From: kasajian@netcom.com (Kenneth Kasajian)
Subject: a shell for internet
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Tue, 5 Jan 1993 09:17:18 GMT


Is there a shell to internet for PC's?  DOS or Windows (or Mac).
Kinda of like a front end program like prodigy.  Although I can get
around using unix, it would be nice to be able to ftp, usenet, rn, mud
all that stuff through some kind of a front end like tapcis, aladin
or bix' jl-blinker.


Newsgroups: comp.unix.shell
From: eric@giga.mks.com (Eric Gisin)
Subject: Re: read not reading
Organization: Mortice Kern Systems Inc., Waterloo, Ontario, CANADA
Date: Tue, 12 Jan 1993 19:07:18 GMT

In article <1993Jan11.210839.9498@progress.com> tucker@bedford.progress.COM (Kyle Tucker) writes:

   cat file | while read LINE
   do
	   if [ certain things are true about $LINE ]
	   then
		   do some stuff based on values in $LINE
	   fi
   done

   Now, if I do "some stuff" , which is a lot of text hacking, etc, but
   absolutely no exits,breaks,continues,etc, the read command sees no
   more lines in the file. If I don't do "some stuff", then it reads next
   line fine. sh -x shows the read is actually occuring, but ending as
   if it sees EOF. Has this been seen before? This also occurs if the reads
   are done through standard input.

---

Most likely one of the commands in "some stuff" reads stdin.
The only safe commands to read stdin in a shell script like this
are the "read" built-in and "line", which should do unbuffered input.
Commands like "head -3" and "sed 3q" may read a complete buffer from the pipe
(probably the rest of "file") and the next "read" will get EOF.

Least likely is the shell does fflush(NULL) before forking on a POSIX.1 system.
This will discard the stdin buffer in shells that use stdio.
Newsgroups: comp.unix.shell
From: k202047@galilei.DKRZ-Hamburg.DE (H.Thiemann)
Subject: Problem with make
Keywords: make
Organization: Deutsches Klimarechenzentrum GmbH, Hamburg
Distribution: dkrz
Date: Wed, 6 Jan 93 16:19:23 GMT

I have just received a makefile with a dependency parameter like $$(@F)
It causes an error message like this: Make:  Don't know how to make @F.  Stop.
Is it possible to substitute this parameter by another.
Thanks a lot for help
H. Thiemann
From: georgeq@g2syd.genasys.com.au (George Quinlan)
Subject: Re: testing if an arg is a number
Organization: Genasys II, Sydney, Australia
Date: Tue, 5 Jan 1993 06:57:46 GMT

In article <6077@sixhub.UUCP> davidsen@sixhub.UUCP (bill davidsen) writes:
>In article <1hruvtINNbap@sam.ksu.ksu.edu> dudley@sam.ksu.ksu.edu (D U D L E Y) writes:
>| Was curious, and didn't see it in the FAQ...how would you identify if an
>| argument to a script is *entirely* numeric?
>| 
>| So "12" would return true while "12a" would return false.
>| 
>| The only way I found was to use egrep.
>
>See also expr.
>
>  expr "$n" : "^[0-9][0-9]*$" > /dev/null && echo numeric || echo other
>

I was recently asked a similar question and offered this solution:

#!/bin/sh

isnum()
{
	echo $1 \
	| awk '\
	{
		num = $1 + 0;

		if (num == $1)
			exit(0);
		else
			exit(1);
	}'
	return $?
}

isnum $1 && echo "numeric" || echo "not numeric"

It has the advantage that it recognises valid floating point numbers
(including those in exponential format) as well as integers.
-- 
George Quinlan		       Genasys II, 33 Berry St, North Sydney, Australia.
What is the difference between ignorance and apathy?
I don't know, and I don't care.
Newsgroups: comp.unix.shell
From: mike@uunet!tellab5!odgate (Mike J. Kelly)
Subject: Re: book on shell programming
Organization: Odesta Corporation
Date: Tue, 5 Jan 1993 23:33:08 GMT

pjh@mccc.edu (Pete Holsberg) writes:

>In article <1993Jan4.171014.3369@samba.oit.unc.edu> Gary.Moh@launchpad.unc.edu (Gary Moh) writes:
>=Could someone recommend a couple of books on shell programming please??

>"UNIX Shell Programming" by Kochan and Wood, Hayden Publ.

Also, "The Unix Programming Environment" by Kernighan and Pike (Prentice-Hall).
It covers more than the shell, but is a very good shell book as well.  The
authors say most users of Unix are programmers, but are programming in the 
wrong language -- they should be using shell for much of what they do.
Newsgroups: comp.unix.shell
From: mitra@pandora.sf.ca.us (Mitra)
Subject: xargs with no arguments
Organization: Pandora Systems
Date: Sat, 9 Jan 1993 22:09:51 GMT
X-Newsreader: TIN [version 1.1 PL6]


Is there any easy trick to persuade xargs not to execute if there are no
arguments presented on stdin, I'm running it in a cron task, and often
the command being xarg-ed will report an error if there are no arguments
to delete/index/whatever.

- Mitra
From: dtb@otto (David Bath)
Newsgroups: comp.unix.shell
Subject: Re: Curses like menu in a bourne shell script
Date: 7 Jan 93 04:11:37 GMT
Organization: RMIT Computer Centre
NNTP-Posting-Host: otto.bf.rmit.oz.au

pm0@bale.cis.ufl.edu (Patrick Martin) writes:

>I wish to create a bourne shell menu which will read the cursor
>keys and scroll a highlighted bar across a list of menu items.
>I wish for return on a menu item to select that menu item.

>Sounds alot like curses I know.

>I dont want the solution to be entirely bourne shell (ie: I do
>not wish to write a supporting C routine to perform any subtasks).
>I also do not wish to have to write a termcap.

>Is this possible or is it too much to ask of bourne shell?

>Thanks (I hope) in advance,

>Pat

Check out the tput(1) command which uses output curses strings to the
terminal.

Guess you would have to keep the lines of text and positions in strings.

Reading the cursor keys or whatever will require a small C program.

David T. Bath	Email:dtb@otto.bf.rmit.oz.au	Phone:03-3477511
Global Technology Corporation, 179 Grattan St, CARLTON, VIC, 3153, AUSTRALIA
"Failure to emulate is the best revenge" - Marcus Aurelius
-- 
David T. Bath	Email:dtb@otto.bf.rmit.oz.au	Phone:03-3477511
Global Technology Corporation, 179 Grattan St, CARLTON, VIC, 3153, AUSTRALIA
"Failure to emulate is the best revenge" - Marcus Aurelius
Newsgroups: comp.unix.shell
From: mich@lin.infolog.se (Thomas Michanek)
Subject: Extracting regular expressions using egrep/sed/...
Organization: Infologics, Linkoping, Sweden
Date: Tue, 5 Jan 1993 13:51:45 GMT


I have two questions concerning csh programming:

1. Let's say I have a variable $var containing >1 words of text.
   I want to know if this variable contains a specific pattern in the
   form of a regular expression. The way I do it now is:

     if ("`echo $var | egrep '<regexp>'`" != "") then ...

   I have to double quote since egrep returns >1 word when matching.
   Otherwise I get an 'if: expression syntax' error.

   Is there an easier and/or faster way to do this test? (in csh please!)


2. Now that I know the variable contains what I want, I want to extract
   the part(s) of the variable value that matches the regular expression.
   Let's say I'm looking for integers (i.e. [0-9]+) and $var contains:

     Is 54 greater than 33?

   I want to extract the values "54" and "33" (not "33?") out of this string.
   How do I do that? egrep can't help since it returns the whole string.
   I've looked at sed and tried to find a way to delete the characters
   _not_ matching the regexp, something like "sed 's/!regexp//g'". I've
   read about the 'hold space' in sed and replacing the 'pattern space'
   with that, but the 's' command doesn't seem to use the 'hold space'?
   And yes, I know that for the simple example above I could do:

     echo $var | sed 's/[^0-9 ]//g'

   but what if the regexp is very complicated? Please note that the regexp
   may span over several words, so I can't loop through each word in $var
   and see if it matches.


Any pointers are much appreciated!

.- - - - - - - - - - - -.  _ _  _ ___ _  _   _   _  _  _  _   .- - - - - - - -.
|    Thomas Michanek    |  | |\ | |_ / \ |  / \ / _ | / `|_`  | Dial +46 13   |
|  Infologics Linkoping |  | | \| |  \_/ |_,\_/ \_| | \_,._|  | 210060  Phone |
| email:Thomas.Michanek |          _                          | 210068  Direct|
|       @lin.infolog.se |  L I N K O P I N G  -  S W E D E N  | 210155  Fax   |
`- - - - - - - - - - - -'                                     `- - - - - - - -'
Newsgroups: comp.unix.shell
From: jefouger@nyx.cs.du.edu (Jim  Fougeron)
Subject: Re: alias probem in tcsh and csh
Organization: University of Denver, Dept. of Math & Comp. Sci.
Date: Mon, 4 Jan 93 08:30:56 GMT

rduta@nyx.cs.du.edu (Radu) writes:

>I was trying to create some aliases for ls, and i ran into some minor
>problems, well for starters i'll list my aliases:
>alias ls 'ls -F \!* | more'
>alias dir 'ls -aol '

>Ok, her's are the problems: I'd like to put a "more" in the dir alias as well,
>but it conflicts with the ls, and the space bar doesn't work for paging any
>more.  The second probelm i encountered was doing something like "ls m*", it
>listed all the files, then went ahead and started to list the contents of the
>files, as thought I did a "more m*".  I'm not sure what the problem is so
>if anyone has any ideas on what is going wrong or ways to solve the problem
>please let me know. 
>(i'd like to add the "\!*" to the dir alias as well)

try this for dir:  alias dir '/bin/ls -aol \!* | more'

>radu

>--
>********************************************************************************
>I only kill to know I'm alive!
--
----------------------------  ^  What is the TRUE meaning of happiness?  ^
|       Jim Fougeron       |   ^      Is it money, cars and women,      ^
|  jefouger@nyx.cs.du.edu  |    ^        or just money and cars        ^
----------------------------     ^       - Calvin and Hobbes. -       ^
From: davidsen@ariel.crd.GE.COM (william E Davidsen)
Newsgroups: comp.unix.shell
Subject: Re: ksh: expression eval feature or bug?
Date: 7 Jan 93 17:23:32 GMT
Reply-To: davidsen@crd.ge.com (bill davidsen)
Organization: GE Corporate R&D Center, Schenectady NY

In article <C0GF6p.JxJ@cmptrc.lonestar.org>, marc@cmptrc.lonestar.org (Marc Elewitz) writes:

| $print $(((1+2)))
| + print 3
| 3
| 
| 	Although '((1+2))' sends nothing to stdout, 'print $(((1+2)))' displays
| 	the expression result.  Why??

  You're misreading the expression. Parenthesis are allowed in
expressions, so you're evaluating the expression (1+2) which has a
result very similar to 1+2 without the parens.


-- 
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
    Keyboard controller has been disabled, press F1 to continue.
Newsgroups: comp.unix.shell
From: patrick@casbs.Stanford.EDU (Patrick Goebel)
Subject: switch/case question under csh
Organization: Center for Advanced Study in the Behavioral Sciences
Distribution: comp
Date: Thu, 7 Jan 1993 23:55:00 GMT

In a switch statement under csh, I need a case that traps the [
character (among others).  However, all the case statements I have
tried yield a "Missing ]" error.  Here's what I've tried so far:

case "[":
case "\[":
case \[:
case "[[]":
case "[\[]":
case "'['":
case '[':

Does anyone know the magic incantation that quotes the [?  I need to
do the same thing with some other "trouble" characters like * and _
(underscore).

Thanks in advance for any pointers.

Cheers,
patrick
--
Patrick Goebel                    E-MAIL: patrick@casbs.Stanford.EDU
Network Administrator             VOICE:  (415) 321-2052
CASBS, 202 Junipero Serra Blvd.   FAX:    (415) 321-1192
Stanford, CA 94305                BEEPER: Temporarily Out of Order...
Newsgroups: comp.unix.shell
From: mjones@amex-trs.com ()
Subject: Insterting a line into a file with ksh
Reply-To: mjones@amex-trs.com
Organization: American Express TRS	
Date: Thu, 7 Jan 1993 15:15:44 GMT

I would like to take a file such as


xxxxx xxxxx xxxxx xxxxxx
xxxxx xxxxx xxxxx xxxxxx

aaaaa aaaaa aaaaa aaaaaa
aaaaa aaaaa aaaaa aaaaaa


and insert a line such as "zzzz zzzz zzzz zzzz" after the xxxxx line
but before the aaaaa line.

How can I do this in ksh?  The file is too complex to slice it apart
and reconstitute up with 'grep' and 'cat'.  If 'sed' is the answer,
I don't know what the 'sed' command should look like in this case.

Please repond by e-mail or phone.

Mark Jones
mjones@amex-trs.com
mjones@rsv08.cslab-tgsc.amex-trs.com
(602)492-4176
Newsgroups: comp.unix.shell
From: randy@ess.mc.xerox.com (Randy Stegbauer)
Subject: Re: need a bit of help in
Reply-To: stegbauer.wbst129@xerox.com
Organization: Xerox, Rochester, NY
Date: Tue, 5 Jan 1993 14:00:31 GMT

In article 23031@mnemosyne.cs.du.edu, rduta@nyx.cs.du.edu (Radu) writes:
>>
>>2) I was wandering what is the easiest way to do a recursive grep, where

In article 20122@newscan.canada.sun.com, beric@sunvcr.canada.sun.com (Beric Maass - Sun Vancouver SPS) writes:
>
>find . -type f -exec grep -i string_to_search /dev/null {} \;


This works fine when none of the directories are symbolic links.  However 'find' does not follow links.  I use the following shell script for recursive greps.  (Please excuse the fact that it is a csh script.  I wrote it before I was enlightened to sh programming.)

--------------------- BEGIN script rgrep ---------------------
#!/bin/csh -f

if ($#argv < 3) then
	set _program = $0
	echo usage: $_program:t directory pattern_to_find files_to_search...
	echo        use single quotes around 'pattern' and 'files'
	echo        if they contain meta-characters.
	exit 1
else
	set _curr_dir = $1; shift
	set _pattern = "$1"; shift
	cd $_curr_dir
	grep "$_pattern" $argv /dev/null |& \
		sed -e "/^grep: .*: No /D" \
		    -e "/^grep: .*: Is a directory/D" \
		    -e "/^No match./D"\
		    -e "s@^@$cwd/@"
	set _next_dirs = ( .[^\.] .??* * ) >& /dev/null
	if ( $#_next_dirs != 0 ) then
		foreach file ( $_next_dirs )
			if ( -d $file ) $0 $file "$_pattern" "$argv"
		end
	endif
endif
--------------------- END script rgrep ---------------------

---
Randy Stegbauer
Phone: (716)422-3236
Mail: stegbauer.wbst129@xerox.com
From: d3a061@aggie.oname (ZT Taylor)
Newsgroups: comp.unix.shell
Subject: SUMMARY: Bourne shell functions & 'exit'
Date: 12 Jan 93 16:07:25 GMT
Article-I.D.: oracle.1993Jan12.160725.19922
Reply-To: d3a061@aggie.oname
Organization: Pacific Northwest Laboratory


My original question:

> Bourne shell functions seem to be inconsistent in the way they handle an 'exit'
> statement.  For example, the following:
> 
> 	func() {
> 		.
> 		.
> 		exit 1
> 	}
> 
> 	func
> 
> causes the whole shell script to exit, while this:
> 
> 	func() {
> 		.
> 		.
> 		exit 1
> 	}
> 
> 	junk=`func`
> 	echo $?
> 
> doesn't.  At first I thought this meant func was executed in a subshell, but
> echoing $$ both places gives the same PID.  Is this context-sensitive treatment
> of 'exit' a feature?  Can it be counted on in portable scripts?

Thanks to Don Peterson <donp@hpbs1639.boi.hp.com> and Philip Guenther <guenther@stolaf.edu> for responding.  Philip solved the mystery for me.  It seems
that Bourne shell functions executed in backticks ARE run in a subshell, but per
POSIX standards, $$ in a subshell expands to the PID of the parent.  To quote
the POSIX standard (1003.2 section 3.5.2)...

 3.5.2  Special Parameters

 Listed below are the special parameters and the values to which they
 shall expand.  Only the values of the special parameters are listed; see
 3.6 for a detailed summary of all the stages involved in expanding words.
[...]
    $     Expands to the decimal process ID of the invoked shell.  In a
          subshell (see 3.12), $ shall expand to the same value as that of
          the current shell.

So...the behavior IS reliable and portable.

Todd Taylor
Pacific Northwest Laboratory
zt_taylor@pnl.gov
From: msp@msen.com (Jerry Foster)
Newsgroups: comp.unix.shell
Subject: Print graphics files
Date: 8 Jan 1993 21:46:28 GMT
Organization: Msen, Inc. -- Ann Arbor, Michigan
NNTP-Posting-Host: garnet.msen.com
X-Newsreader: TIN [version 1.1 PL8]



--
  //  Jerry Lee "3P"
\x/   e-mail: jfos@msp.com
From: jonr@ifi.uio.no (Jon Ross)
Newsgroups: comp.unix.shell
Subject: Re: How to make Restrict Shell more safely?
Date: 6 Jan 93 07:52:36 GMT
        <1993Jan4.194925.7364@crd.ge.com> <1993Jan4.200035.7840@crd.ge.com>
        <1ibbd7INNiml@mudos.ann-arbor.mi.us>
        <1993Jan5.165446.15449@crd.ge.com>
Organization: University of Oslo, Norway
        Jan 93 16:54:46 GMT
Originator: jonr@solva.ifi.uio.no

In article <1993Jan5.165446.15449@crd.ge.com> davidsen@ariel.crd.GE.COM (william E Davidsen) writes:

> In article <1ibbd7INNiml@mudos.ann-arbor.mi.us>, mju@mudos.ann-arbor.mi.us (Marc Unangst) writes:
> | In article <1993Jan4.200035.7840@crd.ge.com> davidsen@crd.ge.com (bill davidsen) writes:
> | Hmm.  Is vi part of the /guest/bin environment?  If so, all the user
> | has to do is "vi foo", then do ":set shell=/bin/sh" and ":!/bin/sh".
> | Presto, they have an unrestricted shell.
On my Sun SS2 running SunOS 4.1.3, after trying the trick above,
as a user with /usr/lib/rsh as login shell, i get  this error
message from vi:
sh: /bin/sh: restricted
And vi doesn't shell out.

Jon R.
Newsgroups: comp.unix.shell
From: s4uhkm@fnma.COM (Howie Michalski)
Subject: mail question???
Reply-To: s4uhkm@fnma.COM
Organization: Fannie Mae
Date: Tue, 5 Jan 1993 21:18:45 GMT

I have a file of the containing messages I would like to send out via mail.
The format is as follows:

	To: user@machine
	From: user@machine
	Subject: lkdjflksjdflksjf
	text text text....

	To: user@machine
	From: user.....

and so on - anyone know how I can process this file so that the messages can be sent
out??

Howie


---
#include <Std_Disclaimer>  /* Howard Michalski,    howie@fnma.COM   *
#define OPINIONS "My own"   * Fannie Mae, Unix Technical Services   *
 			    * 3900 Wisconsin Avenue NW              *
main(){for(;;);}	    * Washington, DC, USA           20016   */
From: davidsen@ariel.crd.GE.COM (william E Davidsen)
Newsgroups: comp.unix.shell
Subject: Re: How to make Restrict Shell more safely?
Date: 4 Jan 93 19:49:25 GMT
Reply-To: davidsen@crd.ge.com (bill davidsen)
Organization: GE Corporate R&D Center, Schenectady NY

In article <cslee.225.726145569@pds.nchu.edu.tw>, cslee@pds.nchu.edu.tw (Lee Chee Siong) writes:
| Hi,
|   I want to creat a few accounts in Restrict Shell enviroment. In this 
| account, only a few command(e.g. vi, ftp, mail, news) can be used. Is
| there any suggestion to creat this environment to make it more security
| in my system?
|   Any comming is appreciate.

Okay, here's how... I'll show it for putting all the users in /guest,
since that's how I do it.

  1. Create the directory /guest/bin, and put all the stuff you want in
there, as wellas your shell.

  2. Create the guest user accounts, as /guest/user1, or /guest/joe, or
whatever. The sticky bit should be set on these directories, mode 1711
is suggested.

  3. Create a .profile file in /guest, *owned by bin*, and link it into
each user's home directory. Set permissions 644. This prevents the user
from changing or deleting the profile. In the profile set the PATH to
/guest/bin and set the variable *readonly*
	PATH=/guest/bin
	export PATH
	readonly PATH

  4. Remember that some programs give shell access via escapes, like vi,
emacs, etc. Some versions use PATH and are safe, some use /bin/sh and
are not at all safe.

  5. The *really* safe way to have guest users is to run them in a tiny
system of their own using chroot. It is very hard to do this without
losing a lot of functionality, however, so I don't do that. I limit what
they can run, use shadow password, and have been pretty happy with the
resulting security.

-- 
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
    Keyboard controller has been disabled, press F1 to continue.
Newsgroups: comp.unix.shell