[comp.windows.news] Beginning user questions

meh@wucs1.wustl.edu (Mark E Hunter) (01/17/90)

        Several questions in regards to NeWS:

        NeWS supports a user stratup file called user.ps This file
        resides in the user's home directory and consists of NeWS
        commands to be executed upon startup

     1) I cannot get the root account to execute its user.ps
        It is a valid script and has been tested using other 
        accounts and by executing it manualy using the psh
        command.

     2) I have a number of scripts that will execute when psh'ed,
        but will not run as user.ps.  These scripts contain one or 
        more windows to create upon NeWS startup.  Some of these
        scripts ran a one time but a minor edit (changing the order
        of the windows being created or adding a comment) resulted
        in their not working.  

        Some scripts execute only some of the commands contained.
        They do not seem to start at either end of the script and
        break.  They select random statements to execute.  Others
        run one session but not another.

        This seemingly random behavior was explained by Sun as
        timing problems.  Their explanation was that the user.ps
        was running before NeWS was fully operational.  They did
        not have a way to get these scripts to execute properly.

     3) I have need to start NeWS and then run a NeWS script 
        automatically.  I have a csh script which starts NeWS
        and runs the NeWS script but because of the timing problem
        above, sometimes the NeWS script is executed before NeWS
        is fully functional.  Does anyone know of a way to check
        to see if NeWS is up ?  Does anyone know of a way to get
        the script to wait for NeWS to be up before continuing ?

Thanks,

Mark E. Hunter

meh@wucs1.wustl.edu

montnaro@spyder.crd.ge.com (Skip Montanaro) (01/17/90)

In article <1990Jan16.171713.15038@cec1.wustl.edu> meh@wucs1.wustl.edu 
(Mark E Hunter) writes:

	2) I have a number of scripts that will execute when psh'ed,
	   but will not run as user.ps.  These scripts contain one or 
	   more windows to create upon NeWS startup.  Some of these
	   scripts ran a one time but a minor edit (changing the order
	   of the windows being created or adding a comment) resulted
	   in their not working.  

	   Some scripts execute only some of the commands contained.
	   They do not seem to start at either end of the script and
	   break.  They select random statements to execute.  Others
	   run one session but not another.

	   This seemingly random behavior was explained by Sun as
	   timing problems.  Their explanation was that the user.ps
	   was running before NeWS was fully operational.  They did
	   not have a way to get these scripts to execute properly.

The issue of startup files in NeWS 1.1 is one that bit me long ago. I
suspect it's bitten others as well, so I'll post the workaround I received
from comp.windows.news. I'm surprised that Sun couldn't give a more complete
workaround/fix for the problem.

The problem is that $NEWSHOME/lib/NeWS/init.ps loads ~/user.ps before it
spins off the NeWS lightweight process that listens for client connections.
It's a race to see if the listener process can get started before
applications start requesting connections. The fix is to split user.ps into
two parts, say user.ps and desktop.ps. In user.ps is code you want loaded
into the server at startup time. Desktop.ps should contain client program
invocations. Modify init.ps so that desktop.ps is executed after the server
process is started:

  (user.ps) LoadFile pop

  DebuggingServer? {
      systemdict /dbgstart known not {(NeWS/debug.ps) LoadFile pop} if
  } if
  (NeWS/AdobeMap.ps) LoadFile pop
  StandardEncoding
  magic:AdobeSequence {
      dup 256 lt { exch put //StandardEncoding } { pop pop } ifelse
  } forall pop

  % start server
  verbose? { (Starting server\n) print } if
  server

  % Give the user the chance to start programs after the server is listening
  % for connection requests. This idea is not original from me. I got it from
  % comp.windows.news.
  % - Skip Montanaro, 11/23/88
  (desktop.ps) LoadFile pop

Note that this is not a problem in X/NeWS (aka OpenWindows, aka NeWS 2.0).
~/.openwin-init is executed after the server starts.

--
Skip (montanaro@crdgw1.ge.com)