[comp.unix.questions] Problem with scripts in ksh

acp@ms.uky.edu (ACP Network) (01/10/90)

I hesitate to call this a bug right away, but ksh on two of our machines
seems to have trouble executing scripts.  I've tested this on a vax
running ultrix (3.1?) and a sequent running dynix, with the same
results.

Any script that starts out with
#!/bin/ksh
executes fine as long as the statements are internal to ksh (eg, echo,
if/then/fi, etc) but hangs after executing the first external command
(I've tested it with ps, cat, grep, and sed).  For instance, a script such as

#!/bin/ksh
ps -a
echo 'done.'

executes the ps -a then hangs with no message.  ^C will break out of it, 
but the second echo never executes.  Any statements internal to ksh placed 
before the ps line will execute normally.

Taking out the #!/bin/ksh line makes the script work properly (my default
shell is ksh anyway).  Changing it to #!/bin/sh or #!/bin/csh makes
the script work properly (if the internal commands are compatible with
the new shell, of course).  It also runs properly on a machine running
SYSV/386 3.2.

Is this some obscure feature I don't know about? :-)

Kenneth Herron
-- 
acp@ms.uky.edu        University of Kentucky         ACP Network Consultant
ukma!acp         Dept. of Mathematics, room 715 POT          (606) 257-2975
                       Lexington, KY 40506

rjk@sawmill.uucp (Richard Kuhns) (01/10/90)

In article <13632@s.ms.uky.edu> acp@ms.uky.edu (ACP Network) writes:

   [...] ksh on two of our machines seems to have trouble executing scripts.
   [...]
   executes fine as long as the statements are internal to ksh (eg, echo,
   if/then/fi, etc) but hangs after executing the first external command
   (I've tested it with ps, cat, grep, and sed).
   [...]
   Is this some obscure feature I don't know about? :-)

   Kenneth Herron
   -- 
   acp@ms.uky.edu        University of Kentucky         ACP Network Consultant
   ukma!acp         Dept. of Mathematics, room 715 POT          (606) 257-2975
			  Lexington, KY 40506

This sounds familiar.  No promises, but is it possible you're doing a
`set -o monitor' in your .kshrc/.profile?  As I recall, setting `monitor'
in a non-interactive shell caused ksh to hang after executing an external
command in a script.  I'm afraid I don't remember which version of ksh we
found this problem in.

Hope this helps.

Rich Kuhns
newton.physics.purdue.edu!sawmill!rjk