Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!lll-winken!scooter!neoucom!wtm From: wtm@neoucom.UUCP (Bill Mayhew) Newsgroups: comp.sys.att Subject: Re: Anyone running cnews on a 3b1? (inews problem) Summary: slight differences between sh and ksh Message-ID: <1873@neoucom.UUCP> Date: 15 Jan 90 14:56:12 GMT References: <1990Jan11.023127.13866@ntvax.uucp> <1990Jan14.055820.24@stb.uucp> Organization: Northeastern Ohio Universities College of Medicine Lines: 58 I agree. It sounds like the errors from the egrep in the inews script are due to ksh instead of sh running the script. There are a couple of ways to ensure that a shell program is run under sh instead of ksh. Note that ksh is the usual default shell on the 3b1 for users, and shell programs will normally exeucute under ksh for users. To assure that sh is used, a colon by itself on the very first line indicates that this is an sh program. If the script is being invoked from crontab or some other place, you can put "/bin/sh program" to ensure that you get sh. There is a $SHELL environment variable, but it isn't terribly useful for shell programs run by users. I set my defualt shell to ksh and did "sh test" (see below) and got ksh as the answer. : #"/u/wtm/programs/test" #SHELL variable test program echo Your shell is $SHELL. There is a slight difference in the say the Korn and Bourne shells parse strings apparently. It seems that the Kron shell automatically does an eval as it parses the comand, so ksh scripts require fewer escaped characters than sh scripts. The way around the difference is to assign grep, sed, etc. strings to variables so that the shell only makes one pass on the string and does a clean substitution. Here is an example programming fragment. For sh, you'd have to have: echo Enter news group: \\c read NEWSGROUP DIR=/usr/spool/news/`echo $NEWSGROUP | sed -e s+\\\\.+g` echo News directory is $DIR For ksh you need: echo Enter news group: \\c read NEWSGROUP DIR=/usr/spool/news/`echo $NEWSGROUP | sed -e s+\\.+g` echo News directory is $DIR The following works in either shell: echo Enter news group: \\c read NEWSGROUP SEDSTR="s+\\.+g" DIR=/usr/spool/news/`echo $NEWSGROUP | sed -e $SEDSTR` echo News directory is $DIR Try these these examples in ksh and sh and note the difreent results for fun and amusement. Bill