|
|
Mixing Windows and UNIX
For example, you can pass UNIX environment variables to NeTraverse Merge sessions.
You can also convert text files from
DOS to UNIX format and vice versa.
Working with text files
DOS and UNIX also store text files in different formats. The UNIX system stores text lines as a sequence of characters terminated by a line-feed character. DOS (and Windows), in contrast, terminates text lines with a carriage-return character followed by a line-feed character. A file created in one format can appear corrupted when accessed by the other.
When you use DOS or Windows on your NeTraverse Merge system, you can use any text file that was created with DOS or Windows, because these files are stored in DOS format even when they are created on the shared UNIX filesystem.
To use a text file in UNIX format with DOS programs, you
must convert
the file to DOS text format.
This can be done using the NeTraverse Merge command
"unix2dos".
For example:
unix2dos letter ltr.dos
creates a copy of the UNIX text file "letter" in the new file "ltr.dos"
in DOS text format.
In the same way you can convert from DOS text UNIX text format using
the NeTraverse Merge command
"dos2unix".
For example, the command
dos2unix ltr.dos letter
creates a copy of the DOS text file "ltr.dos" in the new file "letter"
in UNIX text format.
You can use unix2dos and dos2unix both in the DOS and UNIX environment because NeTraverse Merge supplies both DOS and UNIX versions of these utilities.
You can also combine these commands with other DOS or UNIX
commands through pipes and redirection.
For example, the command
dos2unix names.txt | sort > newnames
Restrictions:
Do not specify the same name for the source file and the target
file or try to redirect your output back into the source
file. The following examples are incorrect:
dos2unix names names (incorrect)
dos2unix names > names (incorrect)
Even when you do not know the format of a text file, you can safely use the unix2dos or dos2unix command to convert to the format you need, just to be sure. The commands do not change anything when the file is already in the target format.
Passing UNIX environment variables to DOS/Windows
DOS (and hence Windows) and the UNIX system use similar concepts of
environment variables. An
environment variable
is a
value (assigned by you, the operating system, or an
application) that is available to all commands and
applications that run in the same environment.
You can use DOS environment variables in the NeTraverse Merge environment exactly as you would use them on a conventional DOS and Windows computer.
In addition, you can set UNIX environment variables so they are available to DOS and Windows programs run from the UNIX shell. This is especially useful if you are mixing environments and, for example, using UNIX scripts to gather information that you then pass to your DOS or Windows application.
Use the UNIX DOSENV environment variable to specify any UNIX environment variables you want to pass to DOS and Windows from the UNIX shell, as follows:
DOSENV=variable1,variable2,...
export variable1 variable2... DOSENV
To accomplish these operations, you would type:
MONTH='June'
YEAR='1995'
DOSENV='MONTH,YEAR'
export MONTH YEAR DOSENV
Observe the following rules:
You can run any DOS program from the UNIX command line as follows:
dos program &
In the same way you can run Windows programs:
win program &
For example, you can use the following command to start up the Windows WordPad editor to edit a file.
win wordpad c:file.doc &
Specifying DOS application output behavior
A DOS program that does all its input and output via
standard I/O is called
stream-oriented.
Some standard DOS commands, such as
dir, are stream-oriented programs.
DOS applications that do not write directly to the system
screen (many compilers, for example) are also
stream-oriented programs.
A DOS program that avoids some or all of the standard I/O mechanisms is called display-oriented. DOS applications that write directly to the system video memory (including many text-processing, database, and spreadsheet programs, as well as most games) are display-oriented programs.
To properly handle I/O for a DOS program, NeTraverse Merge must know whether it is stream-oriented or display-oriented. All DOS programs are assumed to be display-oriented unless you specify otherwise.
You can run any DOS program from the UNIX command line with the default assignment of display-oriented. To take advantage of the additional flexibility available with stream-oriented programs, though, you should identify these programs as such, using the +b option.
For example, the following command starts the
application appl as a stream-oriented program:
dos +b appl
When you identify a stream-oriented DOS program with the +b option, you can use UNIX pipe and I/O redirection mechanisms to manipulate the program's input and output.
To determine whether a program is display-oriented or stream-oriented, use these guidelines:
appl > temp
When the program has finished executing, display the
contents of the file you created.
You can do this with
the DOS type command:
type temp
You can also use a text editor to display the contents of the temp file. If the output of your DOS program is correctly captured in this file, the program has stream-oriented output.
To find out whether appl accepts stream-oriented input, you
can test it with a command such as:
appl < con
This command tests input redirection from the console. If appl behaves correctly, it accepts stream-oriented input.
Translating DOS switch characters and path separators
By default, NeTraverse Merge
requires UNIX-style switch
characters and path separators when you issue DOS
commands from the UNIX shell.
For example:
dos +b dir /docs -w
Before passing the command to DOS, NeTraverse Merge
automatically translates this command to:
dir \docs /w
Use the -t option to prevent NeTraverse Merge from translating switch characters and path separators on a DOS command line.
For example, consider a hypothetical DOS compute command,
which does simple arithmetic
calculations like division and subtraction.
With the default translation in effect, a command such as:
dos +b compute 8 - 4
would be translated to:
compute 8 / 4
Obviously, this would not produce the result you had intended.
To prevent this translation, you could type:
dos +b -t compute 8 - 4
The -t option does not prevent the UNIX shell from interpreting metacharacters in a DOS command.
Running UNIX programs from DOS
The NeTraverse Merge
on unix utility allows you to run UNIX programs
from the DOS environment and view the output as
though the programs were actually running under
DOS. You can also view status information
concerning UNIX programs and control their
execution and output from the DOS environment.
Restrictions:
on unix pr -o10 -w65 -l54 -d /tmp/longfilename1
Specify UNIX filenames with their full UNIX names, not with their mapped names.
The "on unix" command runs the specified UNIX process in the current directory of your current drive, provided the drive accesses the shared UNIX file system. If your current drive is not a shared file system drive, the "on unix" command fails and displays an error message.
To execute multiple UNIX commands with a single
"on unix" command, separate the UNIX commands with
semicolons and surround them with parentheses. For
example:
on unix (ls ; cat names)
The "on unix" command automatically converts the text output of the UNIX command from UNIX format to DOS format. That is, the NeTraverse Merge unix2dos utility is built in.
If the "on unix" command cannot execute the requested UNIX command, either
because it cannot find a requested file or because you
do not have execute permission for a requested file, it
returns an error message indicating the name of the
command that the "on unix" command attempted to run.
Using UNIX command names directly
When you want to avoid typing
"on unix", copy or link the on.exe
program to the names of the UNIX
commands you want to run directly from the DOS prompt.
Include the filename extension .exe
in the renamed copy of on.exe.
Assume, for example, that you have a UNIX program called
getname that displays a user's full name when given
either a first or last name. To make
getname executable under DOS, copy
on.exe with the command:
copy j:\NeTraverse Merge\on.exe getname.exe
Then, type the following from the DOS prompt:
getname joe
Alternatively, you can use the
UNIX "ln" command
(
ln(1)
)
to achieve the same result. The linking method saves
disk space since it does not actually duplicate a copy
of on.exe.
For example, to link getname,
from the UNIX prompt, type:
ln -s /usr/merge/dosroot/merge/on.exe getname.exe
You enter all options and arguments following the renamed copy of the on.exe command exactly as you would enter them at the UNIX prompt.
Observe the following precautions and restrictions:
on unix". For example:
on unix mycalendar
on unix type myfile
Search path and other environment considerations
on.exe, any renamed copies of on.exe, and any commands linked to on.exe must be in your DOS search path.
In addition, with any form of the "on unix" command, the UNIX system must be able to find the UNIX command named in the "on unix" command line; that is, the UNIX command must be in your UNIX search path.
NeTraverse Merge executes UNIX commands that you run with the "on unix" command under the standard Bourne shell, sh. Any UNIX environment variables exported by the shell that started your DOS environment are available to UNIX programs executed with the "on unix" command.