🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.software
1 messages
1 total messages Started by Magnus Nordborg Mon, 25 Jan 1993 22:39
Submission: Shell scripts to launch NeXTstep applications from command line
#1709
Author: Magnus Nordborg
Date: Mon, 25 Jan 1993 22:39
180 lines
5536 bytes
	Below are two csh scripts that launch NeXTstep applications from the  
command line.  The first, "nxlaunch", will let you type "nxlaunch Mail" instead  
of "/NextApps/Mail.app/Mail &" or "nxlaunch -o Mail" instead of "open  
/NextApps/Mail.app".  Thus you save typing, and don't have remember the path of  
every application.  

	There is one very useful difference between launching via "open (-o)"  
or directly in background -- using "open" is just like clicking on the app,  
running it the other way is literally launching it from the command line.  For  
example, if you have a terminal open, and use "su" to become another user, then  
type "nxlaunch Mail", that user's mail will be read, whereas the "nxlaunch -o  
Mail" would not.

	This is also useful since "nxlaunch" also takes a "-NXHost" argument:
If I sit at localhost (PublicWindowServer) and rlogin to remotehost, then type  
"nxlaunch -NXHost localhost Mail", my mail on remotehost will be read, whereas  
"nxlaunch -o -NXHost localhost Mail" would read mail on localhost.

	To make this last feature more useful, there is a second script,  
"nxrsh", that is equivalent to "xrsh". Thus you can type (assuming a .rhosts  
file, and the presence of "nxlaunch" on remote host) "nxrsh remotehost Mail".

	These script are public domain, and without any guarantees. Please send  
me improvement and bug reports.

###################### nxlaunch: cut below this line ######################
#! /bin/csh -f
#
#	Finds and launches a NeXTapp from a shell, thus saving you the
#    	trouble of remembering and typing the full path.
#
#	by Magnus Nordborg <magnus@fisher.Stanford.EDU> 
#		Wed Jan 20 13:31:38 PST 1993
#
 
set flags
set useopen

switch ( $#argv )
case 1:
  if ( $argv[1] =~ -h* ) then
    goto usage
  else
    set app = $argv[1]
  endif
  breaksw
case 2:
  if ( "$argv[1]" == "-o" ) then
    set useopen = 1
    set app = $argv[2]
  else
    goto usage
  endif
  breaksw
case 3:
  if ( $argv[1] == "-NXHost" ) then
    set app = $argv[3]
    set flags = "-NXHost $argv[2]"
  else
    goto usage
  endif
  breaksw
case 4:
  set useopen = 1
  set app = $argv[4]
  if ( "$argv[1]" == "-o" && $argv[2] == "-NXHost" ) then
    set flags = "-NXHost $argv[3]"
  else if ( $argv[1] == "-NXHost" && "$argv[3]" == "-o" ) then
    set flags = "-NXHost $argv[2]"
  else
    goto usage
  endif
  breaksw
default:
  goto usage
  breaksw
endsw

# check to see where Apps reside
/usr/bin/dread Workspace ApplicationPaths >& /dev/null	# defined?
if ( $status ) then
  set vmpath = (~/Apps /LocalApps /NextApps /NextDeveloper/Apps /NextAdmin  
/NextDeveloper/Demos)
else
  set tmp = `/usr/bin/dread Workspace ApplicationPaths`
  set vmpath = (`echo $tmp[3] | /bin/awk -F: '{for(i=1;i<=NF;i++) print $i}'`)
endif

# find the App
foreach d ( $vmpath )
  if ( -ed $d ) then
    if ( -ed ${d}/${app}.app ) then
      if ( $useopen ) then
        /usr/bin/open $flags ${d}/${app}.app
      else
        ${d}/${app}.app/${app} $flags &
      endif
      exit 0
    else if ( -ex ${d}/$app ) then		# not in app wrapper
      if ( $useopen ) then
        /usr/bin/open $flags ${d}/$app
      else
        ${d}/$app $flags
      endif
      exit 0
    endif
  endif
end


which echo2 >& /dev/null			# public domain: echo to stderr
if ( $status ) then				#  -- use it if it exists
  echo "$0 : $app not found"
  exit 1
else
  echo2 "$0 : $app not found"
  exit 1
endif

usage:
which echo2 >& /dev/null			# public domain: echo to stderr
if ( $status ) then				#  -- use it if it exists
  echo "Usage: $0 [-o][-NXHost hostname] NeXTapp"
  echo '-o:   use "open" to launch'
  exit 1
else
  echo2 "Usage: $0 [-o][-NXHost hostname] NeXTapp"
  echo2 '-o:   use "open" to launch'
  exit 1
endif

###################### nxrsh: cut below this line ######################
#! /bin/csh -f
#
#	nxrsh -- an equivalent of xrsh
#
#	Usage: nxrsh hostname NeXTapp
#
#	by Magnus Nordborg <magnus@fisher.Stanford.EDU> 
#		Wed Jan 20 13:31:38 PST 1993
#
#	Bugs: I have not been able to come up with a clever way of
#	      finding the correct HOSTNAME -- it has to be set in ".login"
#	      My other shell script, "nxlaunch", is needed to find the app.
#
#   	      There should be a way for this script to make the
#   	      machine PublicWindowServer temporarily -- let me know
#   	      if you find one...
#

set openflag

if( $#argv ) then
  if( "$argv[1]" == "-o" ) then
    set openflag = "-o"
    shift
  endif
endif

if( $#argv != 2 ) then
  echo "Usage: nxrsh [-o] hostname NeXTapp"
  echo '-o:   use "open" to launch'
  exit 1
endif

if( ! $?HOSTNAME ) then
  echo "Environment variable HOSTNAME not set"
  exit 1
endif

# launch it on remote host using "nxlaunch"
/usr/ucb/rsh $argv[1] "nxlaunch $openflag -NXHost $HOSTNAME $argv[2]" &

--


		Magnus Nordborg
		Department of Biological Sciences
		Stanford University
		magnus@fisher.stanford.edu (NeXT mail preferred)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads