<sect1>
<title>Running a DOS application directly from Unix shell</title>

<para>
This part of the document was written by Hans
<ulink
url="mailto:lermen@fgan.de"
>&#60;lermen@fgan.de&#62;</ulink
>.
</para>

<para>
This chapter deals with starting DOS commands directly from Linux.
You can use this information to set up icons or menu items in X.
Using the keystroke, input and output redirection facilities you can
use DOS commands in shell scripts, cron jobs, web services, and so on.
</para>

<sect2>
<title>Using <command>unix -e</command> in autoexec.bat</title>

<para>
The default autoexec.bat file has a statement <command>unix -e</command> at the end. This
command executes the DOS program or command that was specified on the
<command>dosemu</command> command line.
</para>

<para>
For example:
<screen>
dosemu "/home/clarence/games/commander keen/keen1.exe"
</screen>
will automatically:
<itemizedlist>
<listitem><para>
Lredir "/" if the specified program is not available from an
already-redirected drive,
</para></listitem>
<listitem><para>
"cd" to the correct directory,
</para></listitem>
<listitem><para>
execute the program automagically,
</para></listitem>
<listitem><para>
and quit DOSEMU when finished, all without any typing in DOS.
</para></listitem>
</itemizedlist>
Using "-E" at the command line causes DOSEMU to continue after the
DOS program finishes.
</para>

<para>
You can also specify a DOS command, such as "dir". A combination with
the -dumb command-line option is useful if you want to retrieve the
output of the DOS command, such as
<screen>
dosemu -dumb dir > listing
</screen>
In this case (using -dumb, but not -E) all the startup messages that
DOSEMU and DOS generate are suppressed and you only get the output of "dir".
The output file contains DOS end-of-line markers (CRLF).
</para>

</sect2>


<sect2>
<title>Using the keystroke facility.</title>

<para>
Make use of the -input command-line option, such as

<screen>
dosemu -input 'dir &#62; C:\\garbage\rexitemu\r'
</screen>

The '...' will be 'typed in' by DOSEMU exactly as if you had them
typed at the keyboard. The advantage of this technique is, that all
DOS applications will accept them, even interactive ones. A '\' is
interpreted as in C and leads in ESC-codes. Here is a list of the
current implemented ones:
</para>

<para>

<screen>
\r     Carriage return == &#60;ENTER&#62;
\n     LF
\t     tab
\b     backspace
\f     formfeed
\a     bell
\v     vertical tab


\^x    &#60;Ctrl&#62;x, where X is one of the usual C,M,L,[ ...
       (e.g.: \^[ == &#60;Ctrl&#62;[ == ESC )

\Ax    &#60;Alt&#62;x, hence  \Ad means &#60;Alt&#62;d

\Fn;   Function key Fn. Note that the trailing ';' is needed.
       (e.g.:  \F10;  == F10 )

\Pn;   Set the virtual typematic rate, thats the speed for
       autotyping in. It is given in unix timer ticks to wait
       between two strokes. A value of 7 for example leads to
       a rate of 100/7=14 cps.

\pn;   Before typing the next stroke wait n unix ticks.
       This is useful, when the DOS-application flushes the
       keyboard buffer on startup. Your strokes would be discarded,
       if you don't wait.

</screen>

</para>

</sect2>

<sect2>
<title>Using an input file</title>

<para>

<itemizedlist>
<listitem>
<para>
 Make a file "FILE" containing all keystrokes you need to boot DOSEMU
and to start your dos-application, ... and don't forget to have CR
(literal ^M) for 'ENTER'. FILE may look like this (as on my machine):
</para>

<para>

<screen>
2^Mdir &gt; C:\garbage^Mexitemu^M              
</screen>
which could choose point 2 of the boot menu, execute 'dir' with output
to 'garbage', and terminate DOSEMU, where the ^M stands for CR.
</para>
</listitem>
<listitem>
<para>
and execute DOSEMU like this:

<screen>
dosemu -dumb &lt; FILE
</screen>

</para>
</listitem>

</itemizedlist>

</para>

<para>
In bash you can also use
<screen>
echo -e 'dir \gt; c:\\garbage\rexitemu\r' | dosemu -dumb
</screen>
or, when your dos-app does only normal printout (text), then you may
even do this
<screen>
echo -e 'dir\rexitemu\r' | dosemu -dumb &gt; FILE.out
</screen>

</para>

<para>
FILE.out then contains the output from the DOS application, but (unlike the
<command>unix -e</command> technique, merged with all startup messages.
</para>

<para>
You may elaborate this technique by writing a script, which gets the
dos-command to execute from the commandline and generate 'FILE' for you.
</para>

</sect2>

<sect2>
<title>Running DOSEMU within a cron job</title>

<para>
When you try to use one of the above to start DOSEMU out of a crontab,
then you have to asure, that the process has a proper environment set up
( especially the TERM and/or TERMCAP variable ).
</para>

<para>
Normally cron would setup TERM=dumb, this is fine because DOSEMU recognizes
it and internally sets it's own TERMCAP entry and TERM to `dosemu-none'.
You may also configure your video to

<screen>
   dosemu ... -dumb
</screen>

or have a TERM=none to force the same setting.
In all other crontab run cases you may get nasty error messages either
from DOSEMU or from Slang.
</para>

</sect2>

</sect1>

