Technical article 102154

Starting graphical DOS or Windows application from cron on OpenServer.

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

Merge documentation has examples of starting DOS with cron.
When that is attempted with DOS applications that require a
graphical screen, or if a MicroSoft Windows application is run
with cron, this error occurs:           ed:
INIT_FAIL:dos:ERROR:Could not initialize device 'stdin/stdout'

Cause

Cron attempted to start Merge DOS or Windows and could not acquire a particular port or terminal control routines for a Merge DOS/Windows session.

In order to start SCO Merge, it is necessary to own the tty port; cron cannot assign tty ports.

The error message is prompted when Merge fails to determine the tty port, and hence the command fails.

Solution

Use the following steps to create and implement a pseudo initstate, then use "init" to start a DOS or Windows session that will be run by "root" on /dev/tty05, the fifth multiscreen on the console.

1. In this example, tty05 will be used to display a DOS or Windows session run by cron. That tty will need to be disabled with the following command:

# disable tty05

This will disable the getty login on the fifth multiscreen.

Then add the following lines at the end of /etc/inittab and /etc/conf/cf.d/init.base:

dos:a:once:/etc/startdos </dev/tty05> /dev/tty05 2>&1
win:b:once:/etc/startwin </dev/tty05> /dev/tty05 2>&1
chg:ab:once:/etc/change </dev/tty05> /dev/tty05 2>&1

The "dos" line identifies pseudo initstate "a", the "win" line identifies pseudo initstate "b", and the "chg" line identifies action that is taken if the initstate is either a or b.

NOTE:  Additions or changes to /etc/conf/cf.d/init.base will be
used during kernel link by link_unix and idmkinit to create a
new /etc/inittab.
2. Create two scripts, "/etc/startdos" and "/etc/startwin" to give
instructions on starting DOS or windows.  Examples below:
#!/bin/sh
# startdos
TERM=ansi
export TERM
/bin/su root -c /bin/dos  </dev/tty05> /dev/tty05 2>&1
#!/bin/sh
# startwin
TERM=ansi
export TERM
/bin/su root -c /bin/win   </dev/tty05> /dev/tty05 2>&1

NOTE: These example scripts use "tty05" and root user, any other multiscreen up to tty12 may be used and any other user that can run DOS and Windows can be used.

3. Create a third script, "/etc/change" to change the console display to tty05, so that DOS and especially Windows will have its display initialized:

#!/bin/sh
# change
TERM=ansi
export TERM
/bin/echo "\033[04z\n"
NOTE:  "\033[04z\n" is the ansi escape sequence to change the
display to the second virtual terminal "tty05".

4. Run "init q" as root to have "init" re-read /etc/inittab or simply reboot the system in multiuser mode.

To have cron start a DOS or Windows application, simply modify the "startdos" or "startwin" script.

As an example, to start the Windows "clock", edit the following line in the "startwin" script with the following additions:

/bin/su root -c "/usr/bin/win clock" </dev/tty05> /dev/tty05 2>&1

As an example, to start DOS "dir", edit the following line in the "startdos" script with the following additions:

/bin/su root -c "/usr/bin/dos dir" </dev/tty05> /dev/tty05 2>&1

In the above examples "clock" and "dir" are in the path for the DOS or Windows session. Ensure that any DOS or Windows command that is attempted to run with this script is included in the path statement for DOS and/or Windows.

NOTE: DOS and Windows will not normally exit or quit without a
 command to do so, this behavior may depend on whether or not the
 application requires input to continue, or can just run by itself
 to completion and exit the session.  The user or administrator
 will need to configure the DOS or Windows cron session for the
 behavior desired.
NOTE:     After init has re-read /etc/inittab, the above steps can be
          tested with "at", as in the example below, to start DOS and the
          desired application entered in /etc/startdos:
# at now +2 minutes
init a
^d

In two minutes dos and desired application will start on "tty05".

See also

man (F) inittab, man (M) init, man (MERGE) dos, man (C) su, man (ADM) idmkinit, man (ADM) link_unix, SCO Merge User's Guide

From the Xinuos technical article database, record 102154. Reproduced with permission. The original is at www.sco.com/ta/102154, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.