Problems with running scripts in DECTERM windows from apps

Problems with running scripts in DECTERM windows from apps

Post by Kent Willia » Thu, 17 Jun 1993 23:48:51



OK VMS Wizards, here's a good one for you:

We have an application that comes as a pile of executables that get spawned
from a X Windows interface.  One of the things we do under Unix is start
an X term as a backround process, and have it run a shell script.

So for the grand and glorious Port to VMS, I tried the direct approach:

simply replace all these

system("xterm -e sh gumby_script &");

with


In a word, NOT! For some reason, you do a "CREATE /TERM/NOWAIT" from
system().  The frame shows up on the display to be placed, and then disappears
once you place it.  Hmmm....

Next try -- use lib$spawn.  Roughly the same results.  Grrr....

Final try -- use lib$spawn with NOWAIT to run a DCL script, that builds
ANOTHER script file, which it then runs with CREATE/TERM/WAIT.  That works!
For example


                                     * lib$spawn
                                         */

where gumby_dcl.com looks something like this

$
$ tmpfile = "sys$scratch" + f$getjpi("","PID") + ".COM"
$ open /write tmp 'tmpfile'
$ write tmp "$ write sys$output ""this is a test ''p1' ''p2' ''p3'""
$ write tmp "$ inquire throwaway ""hit enter to close this window""
$ close tmp

$ delete 'tmpfile';*
$ exit

So my question is, (to quote P.J. O'Rourke) what the f**king f**k?  Why
can't you start decterms asynchronously with system?  Why CAN you start
them from DCL scripts run asynchronously?  Is there some simpler way
to get from here to there?

I come from a Unix backround (Actually my mother was Mormom ...) so have
pity on me -- I'm used to a completely different set of arcane restrictions
and abstruse weirdness.

--

"Science has come with wonderful ways to cure sick people one at a time,
and to kill healthy people thousands at a time" -- guy on NPR

 
 
 

Problems with running scripts in DECTERM windows from apps

Post by David M. Desroch » Thu, 17 Jun 1993 23:43:26


> In article Kent Williams writes:

> OK VMS Wizards, here's a good one for you:

> We have an application that comes as a pile of executables that get spawned
> from a X Windows interface.  One of the things we do under Unix is start
> an X term as a backround process, and have it run a shell script.

> So for the grand and glorious Port to VMS, I tried the direct approach:

> simply replace all these

> system("xterm -e sh gumby_script &");

> with



[text deleted]

how about:

create/term/nowait/input=gumby_dcl_script

--
**************************************************************
* David M. Desroches       * College Computing Center        *

**************************************************************

 
 
 

Problems with running scripts in DECTERM windows from apps

Post by Carl J Lydi » Fri, 18 Jun 1993 07:40:54



=So for the grand and glorious Port to VMS, I tried the direct approach:
=
=simply replace all these
=
=system("xterm -e sh gumby_script &");
=
=with
=

=
=In a word, NOT! For some reason, you do a "CREATE /TERM/NOWAIT" from
=system().  The frame shows up on the display to be placed, and then disappears
=once you place it.  Hmmm....
=
=Next try -- use lib$spawn.  Roughly the same results.  Grrr....
=
=Final try -- use lib$spawn with NOWAIT to run a DCL script, that builds
=ANOTHER script file, which it then runs with CREATE/TERM/WAIT.  That works!
=For example
=

=                                     * lib$spawn
=                                        */
=
=where gumby_dcl.com looks something like this
=
=$
=$ tmpfile = "sys$scratch" + f$getjpi("","PID") + ".COM"
=$ open /write tmp 'tmpfile'
=$ write tmp "$ write sys$output ""this is a test ''p1' ''p2' ''p3'""
=$ write tmp "$ inquire throwaway ""hit enter to close this window""
=$ close tmp

=$ delete 'tmpfile';*
=$ exit
=
=So my question is, (to quote P.J. O'Rourke) what the f**king f**k?  Why
=can't you start decterms asynchronously with system?  Why CAN you start
=them from DCL scripts run asynchronously?  Is there some simpler way
=to get from here to there?

CREATE/TERM creates a subprocess that's running with the created terminal for
input and output.  /NOWAIT means that the process that created the terminal
doesn't wait for that subprocess to exit.  So, if you make the call:

Then:
        1)  The system() function creates a subprocess;
        2)  That subprocess issues the command:

        3)  This causes the creation of a second subprocess and a new terminal
            window;
        4)  Since the first subprocess isn't waiting for the second, it
            immediately exits after the command completes.  Exit of the first
            subprocess, of course, cause deletion of ITS subprocess.
In other words, you're seeing exactly the expected behavior.  What you want is:
        system("create /term/detach/input=gumby_dcl_script.com");
--------------------------------------------------------------------------------

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.

 
 
 

Problems with running scripts in DECTERM windows from apps

Post by Carl J Lydi » Fri, 18 Jun 1993 07:50:00




=
=[text deleted]
=
=how about:
=
=create/term/nowait/input=gumby_dcl_script

'Fraid not.  The subprocess created by system() will STILL exit before waiting
for the subprocess created by the CREATE/TERM/NOWAIT command to finish.  You either
need to use the kludge he mentioned, or use CREATE/TERM/DETACH.
--------------------------------------------------------------------------------

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.

 
 
 

Problems with running scripts in DECTERM windows from apps

Post by M.D.Clay, Boeing Computer Services, (2 » Sat, 19 Jun 1993 04:29:15


Kent,

The problem is your CREATE/TERMINAL command:

The problem is that /NODETACH is the default for CREATE/TERMINAL, so
the created DECterm is a subprocess of the subprocess created by the
system() call.  When the system() subprocess dies, so does the newly
created DECterm.

What you really want is to specify /DETACH instead of /NOWAIT and

detached DECterm.  Your finished system() call should look like:

  system("create /term/detach/input= gumby_dcl_script.com");

You will need to put the following line at the end of GUMBY_DCL_SCRIPT.COM:

  $ stop/id='f$getjpi("","pid")'

If your procedure were to allowed exit normally (via $ EXIT for instance),
the DECterm _window_ will go away but you will be left with an invisible
looping DECterm process that consumes CPU like you wouldn't believe...

Cheer,

        Boeing Computer Services   (206)234-7153
        Seattle, WA                08:30-17:00 PST, Mon-Fri