I previously posted a request for advice on how to spawn an xterm
process from inside VED or pop-11 that then ran a program within the
xterm, without
(a) being killed by an interrupt typed to the original window
(b) inheriting the wrong (VED-like) terminal setting.
I now have a partial answer, thanks to help from John Gibson at
Sussex University.
The problem of inheriting interrupts is solved by piping a command
to csh with the "-i" flag. Thus, instead of something like:
sysobey('xterm -e eliza &')
do
sysobey('echo "xterm -e eliza &" | csh -i >/dev/null')
(redirection to >/dev/null prevents junk coming on the original
screen.).
But nobody has been able to improve on my use of timing to ensure that
the correct terminal setting is inherited by the new process, e.g.
vedscreencooked(); ;;; i.e. not raw
vedscreengraphoff(); ;;; in case of error messages
sysobey('echo "xterm -e eliza &" | csh -i >/dev/null')
syssleep(150); ;;; wait 1.5 seconds
I did find an alternative that works, but it is nasty. I.e. instead
of giving the required command to the xterm via the "-e" flag, use
it to run a shell script, then in the shell script use a call of
stty, in the context of the new xterm, to set terminal handling right.
stty crt
<command>
Anyhow, I now have a procedure to run an xterm on the current or a
remote machine, which reduces the need for a window manager, if you are
using VED. It uses the timing method, but could easily be changed to
write a file and use the other method.
/*
HELP RUN_XTERM
run_xterm(name, command);
This takes two strings, or false and a string, specifying a command
to be run in a new xterm window, on the current machine (if the first
argument is false), or the named machine.
The name is false or a string which is a remote machine name.
The command is a command to be given after the "-e" flag to xterm.
If a specified machine name is given then an "rsh" process running on
that machine is started and xterm is run there with 'command' as the the
command to be run in the xterm window.
If the name is false, then an xterm window is started on the current
machine and the command run in it.
You may require to use a .rhosts file on the remote machine to give
yourself access to it.
On non SunOS machines, e.g. HP-UX or Solaris 2.x, 'rsh' may have to be
replaced with 'remsh' and other consequential changes may be needed,
*/
define run_xterm(name, command);
lvars name, command, display = systranslate('DISPLAY');
if isstring(name) then
;;; ensure $DISPLAY is set, to pass to remote xterm
if isstartstring(':', display) then
;;; add machine name to :0.0
sys_host_name() <> display -> display
endif;
;;; build up a command based on rsh for remote shell
'/usr/ucb/rsh ' <> name <>
' xterm -d ' <> display <> ' -e ' <> command <> ' &'
else
;;; command for xterm on local machine
'echo "xterm -e ' <> command <> '&" | csh -i > /dev/null'
endif -> command;
vedscreencooked(); ;;; set terminal mode normal
vedscreengraphoff(); ;;; in case of error messages
sysobey(command); ;;; do it
syssleep(150); ;;; pause before restoring terminal mode
enddefine;
;;; Example on local machine:
;;; run_xterm(false, 'teach ved')
;;; Example on remote machine called fred:
;;; run_xterm('fred', 'top')
Have fun
Aaron
|