[comp.sys.att] Anyone running cnews on a 3b1?

canoaf@ntvax.uucp (Augustine Cano) (01/11/90)

Hello everyone,

I'm trying to install cnews (up to the latest patchlevel) on my 3b1.  I
finally got all the options right and compiled it with gcc.  When I try
to post to the local test group, inews tells me that the group being
posted to "matches no groups in /usr/lib/news/active".  It seems that
the egrep is failing, but when doing "sh -x inews -h < article", I don't
get that message, the article never gets posted, though.  I have also
extracted the 4 lines that contain the egrep and, when executing them
separately, it indeed finds the group in the active file.

I'm sure someone has encountered this problem before.  Please help!

Thanks in advance.

Augustine Cano		canoaf@dept.csci.unt.edu

michael@stb.uucp (Michael Gersten) (01/14/90)

Yes, I've gotten Cnews to work, and had to patch inews.

There are two shells on the unix pc. One is sh, one is ksh. One wants
4 backslashes on that egrep pattern line, one wants two.

I made it make two tests, and only considered it an error if both failed.

			Michael
-- 
		Michael
denwa!stb!michael anes.ucla.edu!stb!michael 
"The 80's: Ten years that came in a row."

wtm@neoucom.UUCP (Bill Mayhew) (01/15/90)

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