Win4Lin User's Guide |
Chapter 6 -- Using Win4Lin from the command line |
(User's Guide Table of Contents) | (Chapter Table of Contents) |
Previous Chapter - Win4Lin resource administration | Next Chapter - Mixing Windows and Linux |
In general, we recommend that you use the Win4Lin Setup utility in the Desktop environment for most administration tasks.
However, if you don't have the Desktop environment available, or if you want to perform some of the more advanced administration tasks that are not available through the Win4Lin Setup utility, you will find Win4Lin command-line interface useful.
This chapter only documents the usage of Win4Lin administration commands.
For a complete discussion of Win4Lin configuration and administration
options, see
Chapter 4, ``Configuring DOS and Windows sessions''
and Chapter 5, ``Win4Lin resource administration''.
Running DOS and Windows from the Linux command line
You can start DOS and Windows sessions by using the commands dos or win from the Linux prompt.
The DISPLAY environment variable must be set to run Windows and to run DOS properly in a X window.
If the DISPLAY environment variable is not set, the DOS session runs in the xterm window with reduced functionality. Your DOS session will act like a DOS session started on a serial terminal: It will have no graphics, no color, and no DOS fonts available.
You can also start your DOS or Windows session in a window on the Desktop by using the +x option with the dos and win command to make sure the session is run in a proper X window.
Configuring DOS and Windows sessions from the Linux command line
There are two ways to configure DOS and Windows sessions using the command-line interface.
You can configure the session at the time you start it by using various configuration options with the dos and win commands.
You can also modify the default DOS and Windows configurations first by using the winconfig command with appropriate configuration options. Then, any session you start using the dos or win commands will use this modified configuration.
It is also possible to create multiple configurations from which DOS and Windows can be started, so that you can run DOS and Windows using different parameters at any time if you need to.
Using dos and win commands with configuration options
Use the dos and win commands as follows:
dos [ options ] [ dosprogram ]
win [ options ] [ winprogram ]
Options
Specifying options with dos and win commands
overrides equivalent options in the
personal session configurations set either by default
or explicitly with the winconfig command.
The following tokens are available by default for use with the +a option:
You can also specify the read-only (r) and exclusive (e)options after the drive token. For example, to attach the first physical DOS partition in a read-only and exclusive mode as DOS drive E, use:
dos +ae:=dosc,r,e
You cannot use the +kuser:config
option to
specify a session configuration belonging to an NIS-administered user other
than yourself.
See ``The winconfig command''
for more information on personal session configurations.
You can use the winconfig utility to view or change options for your standard DOS and Windows session configurations. You can also create and save alternate configurations.
winconfig accomplishes the same thing as the Personal Win4Lin Session Configuration option of the Win4Lin Setup graphical utility.
The following forms of the winconfig
utility are used for listing, setting, or deleting session
configuration options:
winconfig config list
[option[,option]...]
winconfig config set option=value
winconfig config delete
option=value
Here, config can be dos, win, or another session configuration name. (See "Creating new configurations" for instructions on adding and removing new configurations).
To display the current setting of a given option, use the
list command.
For example:
winconfig win list memory
displays the current memory setting for the standard Windows session configuration (win).
To display all the configuration values for the standard DOS
(dos) and Windows (win) environments, type:
winconfig dos list
winconfig win list
To set or change the value of an existing option, use the
set command. For example:
winconfig win set memory=6
winconfig dos set lpt1=laser,15
To remove a device attachment option
from a configuration, use the delete command.
(This command works only with custom device tokens.)
For example:
winconfig dos delete customdev=sound-card
removes the customdev=sound-card entry from the standard
DOS session configuration.
It does not remove any other customdev entries that may exist.
Setting winconfig options
To change any standard DOS or Windows session configurations, use the set command with the winconfig utility. This command takes option names as arguments. Each option is assigned a value, as follows:
winconfig config set option=value
Legal values for each option are given below. Some values are tokens. (A token is a unique name for a hardware device that is either predefined by Win4Lin or added by the system administrator. You can get a list of available tokens by using the following command: winadmin -list.)
drive=driveletter,drive_name[,readonly][,exclusive]Here, driveletter is the DOS drive letter; drive_name can be none, indicating that the drive is not mapped to anything, a DOS fixed disk in the form dosn, or a token for a virtual drive.
lpt1=token,t
showmenukey="ctrl alt shift F10"
To set the showmenu key to be just the <Home> key:
showmenukey=Home
By default, Win4Lin defines <Shift><F12> as the key sequence.
unzoomkey="ctrl alt shift F10"
To set the unzoom key to be just the <Home> key:
unzoomkey=Home
By default, Win4Lin defines <Shift><F12> as the key sequence.
To create a new configuration in a non-Desktop environment, use the addwinconfig command. This command simply copies an existing configuration to a new name. You can then use the winconfig command to modify it appropriately.
The syntax for addwinconfig is:
addwinconfig existing_config
[copyto] new_config
For example, if you want to create a specific DOS configuration that is similar to your default DOS configuration except that it uses 2MB of expanded memory and a custom device called sound-card, follow these steps:
To
list
all of your existing configurations:
listwinconfig
To
delete
a configuration:
delwinconfig config
You can also borrow a configuration file from another user
by adding the user's user identification to the
existing_config
option of the addwinconfig command.
For example, if user john has created a session
configuration named goodie, and you want a copy
of it, run the following command:
addwinconfig john:goodie copyto myconfig
You must have appropriate read permissions on a user's
home directory before you can copy a configuration.
Win4Lin administration from the Linux command line
If you are not running in the Desktop environment, you can accomplish Win4Lin administration tasks from the Linux command line.
The following commands are available:
In a non-Desktop environment, you can use the winadmin(1) command to manage device definitions. You must be logged in as root to create, modify, or delete device definitions using this command.
This section mainly describes the syntax of the winadmin command. For a complete discussion on device definition and attachment, see ``Device definition'' in Chapter 5.
Each device definition is identified by a unique
token. To list the tokens currently available for attachment, use the
list option, as follows:
winadmin class list
Here, class is one of the following types of tokens:
For example, to find out about tokens available for
attachment as the COM1 serial port, type:
Assume that token dcom1
was listed as one of the available
tokens.
To see its definition, type:
Use the add option of the winadmin command to create new tokens and the update option to modify them.
For example, to create a new COM1 token, use the following command:
Here, token is the token name, file name is the name of a definition file, and full_name is a more descriptive name for the token. The definition file contains all the information necessary for Win4Lin to access this particular device. See ``Tokens and full names'' and ``Definition files'' for details.
To delete tokens you have created but no longer need,
use the delete option, as follows:
winadmin class delete token
For example, to delete the printer token printer1, type:
winadmin printer delete printer1
Do not use the add, update, or delete option with the ems or mouse classes.
Once you create the device definition tokens, you can attach them to a DOS or Windows session by using the +a option of the dos or win command. You can also modify your session configurations by using the winconfig command or the Win4Lin Setup graphical utility in the Desktop environment.
Note, that if you create a new virtual DOS volume token (class dosdrive), you also need to use the mkvdisk command to create the actual Linux file that will contain the new DOS volume before you can attach it to your DOS or Windows session.
Tokens are short names used to identify device definitions.
Tokens must be unique. They can only contain the letters A-Z, the numbers 0-9, and the hyphen (-). The token names should be kept short (no more than 12 characters) to make them easy to use.
Full names (full_name) are more descriptive names for the device definitions. A full name can contain any character, including spaces. However, the entire full_name entry must be enclosed in double quotes when used in a winadmin class add command.
A definition file contains device definition information necessary for Win4Lin to access the device from DOS and Windows sessions. You can use any Linux system text editor to create the definition file.
The definition file can be named anything and can reside
anywhere.
The add option of the winadmin
command only reads the contents of the file in order to update
its internal tables.
You can delete the definition file after you run the winadmin
command.
Definition files for DOS drives
Definition files for DOS drives (or volumes) contain three entries:
attachtype=drive drivename= failureaction=
where:
You should set this entry to warn unless you have special requirements that are best served with the abort or ignore option. Again, note that the failureaction setting is only used when the drive is attached with the exclusive option.
attachtype=drive drivename=/var/vdrive failureaction=warn
Definition files for virtual COM devices
Definition files for virtual attach serial ports contain four entries:
attachtype=vpippi vpidevice= ppidevice= failureaction= irq= ioports=
attachtype=vpippi vpidevice=/dev/vcom1 ppidevice=/dev/tty3a failureaction=warn irq=4 ioports=3f8-3ff
Definition files for print spoolers
Definition files for spooler attach printers contain two entries:
attachtype= printercommand=
attachtype=spooler printercommand=lp -dlaser
If you are using Windows 95, you do not need to attach printers to your session. All available printer definitions show up in the list of available Windows 95 printers.
Definition file for direct attached devices
Definition files for custom direct attach devices can contain one or more of the following:
attachtype= irq= ioports= memmappedio= dmachannel= physicalirq physicalioports physicalmemmappedio physicaldmachannel failureaction= useraccess=The definition file can have any name and can reside anywhere. Use any Linux text editor to create the file.
Here, the form X specifies the I/O port address X (in hex), and the form X-Y specifies an I/O port address range, from low X (in hex) to high Y (in hex) that the device uses. As the syntax shows, single or multiple ports or ranges may be given. Values are typically in the range of 0 to 3ff (hex).
Here, X and Y are two hex numbers, separated by a hyphen, denoting the range of the memory-mapped I/O. The first number is the lowest address and the second is the highest address. Each range must start on a 4K boundary and be a multiple of 4K. As the syntax shows, multiple ranges may be specified. Values are typically c0000 to effff (hex).
This line is used only when attachtype is direct and when irq is also used. It is optional.
This line is used only when attachtype is direct and when ioports is also used. It is optional.
This line is used only when attachtype is direct and when memmappedio is also used. It is optional.
This line is used only when attachtype is direct and when dmachannel is also used. It is optional.
For example, consider a hypothetical adapter card for a widget device. The widget card I/O ports range from 240 to 25f, the interrupt for the card is 7, and the device requires an 8K RAM buffer with a starting address of ce000. The DMA channel field is not relevant for this device. Therefore, the definition file for this device contains the following entries:
attachtype=direct irq=7 ioports=240-25f memmappedio=ce000-cffff dmachannel= failureaction=abort useraccess=rootBe sure that the interrupt, the port ranges, and the RAM address you specify do not conflict with any already existing DOS devices (such as the mouse driver or the EMS driver). If a conflict does exist, you should change the settings on your hardware device. If you need to change the default settings for the mouse driver instead, refer to ``The mouse'' in Chapter 5.
Incorrect use of device specifications for a direct attach custom device can crash the Linux system. You should install and test the device in system maintenance mode and at a time when users are not inconvenienced if you need to reboot the system.
During this testing phase, you may have to fine tune the
entries in your definition file.
Instead of continuously
deleting a token and adding it again, you can use the
update option of the winadmin
command.
For example, if you want to change an entry in the
definition file for
widget, edit the definition file, make the desired change,
and then type:
winadmin custom update widget:def-file:"Widget Adapter"
You can continue this testing process until you have a definition that works. Then, you should clear the useraccess= entry so others can use the device; you may also change the failureaction= entry from abort to an option appropriate to your environment.
Directly attached devices cannot be shared.
As long
as one process is using a directly attached device,
other processes are prevented from using the device
until the process controlling the device exits.
Creating virtual DOS volumes using the mkvdisk command
You can create the virtual DOS drive volume associated with the new device
definition token created by the winadmin dosdrive command
by issuing the following command from the proper directory:
/opt/win4lin/mkvdisk
[-s] filename size
Here, filename is the name of the Linux file that will be used as the virtual volume, size is the size of the drive in kilobytes, and the -s option, when present, allocates the full size when you create the drive.
By allocating this space when you create the drive, you ensure that it is available in the future. If you omit the -s option, mkvdisk creates only a small file as a placeholder. However, this file can grow as your DOS programs use the virtual drive to store files as long as there is sufficient space on the Linux file system to accommodate the growth.
For example, to create a 5MB virtual DOS drive named mydrive.dsk
in your home directory and allocate the full size at
creation, type:
/opt/win4lin/mkvdisk -s mydrive.dsk 5000
Configuring running sessions from the DOS command line
The following Win4Lin commands allow you to configure your
current session from the DOS prompt:
The syntax for selecting a
print stream, a printer, and a Linux print command is:
Here, n is 1, 2, or 3 and indicates whether you are using LPT1, LPT2, or LPT3.
prt_cmd specifies the Linux print command that should be used to process the DOS or Windows print requests you send to this port. If you use the /r option instead of specifying a print command, Win4Lin passes the print stream to the Linux default print process.
timeout is the number of seconds you want Win4Lin to
wait without receiving print data before it passes the
print stream to the Linux command.
The timeout value can
be in the range 5 to 3600; the default is 15.
When you set /t0, print breaks (that is, when the print stream is
sent to the Linux command) never occur as a result of a timeout.
Instead, the print stream is sent when the
DOS application requesting printing exits (/x1, which
is the default setting for the printer command).
When you set /x0, the print stream is not automatically sent
when the DOS application exits.
Setting both /x0 and
/t0 causes Win4Lin to hold the print stream until you
explicitly request a print break by typing:
printer lptn /p
To discard print jobs that are being held, type:
printer lptn /d
For example, to direct DOS print output sent to LPT2 to a Linux printer called laser, follow these steps:
In this command, the -d (destination) option on the lp command identifies the printer named laser.
You can direct printer output from DOS applications to any Linux printer using the same procedures.
Note that the prt_cmd that you specify when you use
the printer command is typically
lp -d printer, where printer is the name of a
Linux printer.
However, prt_cmd
can be any Linux command that you
choose to use to process a print stream.
Tuning application execution using the merge command
The merge
command allows you to tune the operation of the
DOS and Windows 3.1 sessions for certain applications.
(Windows 95/98 is not affected by the merge command)
Unlike the configuration options, you use the merge command to set characteristics of the DOS or Windows environment only from within DOS.
With the merge command, you can:
Unlike standard DOS and Windows 3.1, Win4Lin automatically puts applications that continuously poll the keyboard to sleep until there is keyboard input.
Some applications may appear to be in a polling loop when they actually are not. The Win4Lin default to put these applications to sleep causes them to perform poorly in the Win4Lin environment. This situation is not common, but if you encounter it, you can disable the sleep feature.
To disable the Win4Lin default of putting applications that
continuously poll the keyboard to sleep, type the
following at the DOS prompt:
Win4Lin set pollsleep off
To return to the standard Win4Lin default, type:
Win4Lin set pollsleep on
Handling DOS application network transactions
From the point of view of some DOS and Windows applications,
the Win4Lin file system is a network device.
These applications use various DOS system calls to
determine whether and how they should operate.
An application may enable or disable file locking, for
example, based on its tests of network status.
The four merge
command options described in the following
sections (drive, handle, netbios, and
5f02) have
defaults that allow DOS applications to run correctly
when they access the Linux file system.
Specifying local and remote drives
Some DOS and Windows 3.1 applications detect whether a DOS drive is local or
remote by using the DOS interrupt 21H system call
function 44H (IOCTL) code 09H (Is Logical Device
Local or Remote).
These applications may not operate
correctly if a DOS drive is remote when the
application expects it to be local or vice versa.
Win4Lin always treats your personal drive C as local; by default, it treats
other Linux drives (such as D and J) as remote drives. You can change
this setting for all non-personal Linux drives by typing the following command
at the DOS prompt:
merge set drive local
If you always want these drives treated as local, you can insert this command in your autoexec.bat file.
To return to the Win4Lin default -- interpreting Linux drives
as remote -- type:
merge set drive remote
Specifying local and remote files
Some DOS and Windows 3.1 applications detect whether a DOS file is local or
remote by using the DOS
interrupt 21H system call
function 44H (IOCTL) code 0AH (Is Redirected
Handle).
These applications may not operate
correctly if a DOS file is interpreted as remote when
the application expects it to be local or vice versa.
Win4Lin always treats files on personal drive C as local; by default, it treats files on other Linux drives (such as D and J) as remote files.
Type the following command at the DOS prompt
to configure your environment so DOS interprets files
on non-personal Linux drives as local:
merge set handle local
If you always want files on these drives treated as local, you can insert this command in your autoexec.bat file.
To return to the Win4Lin default, type:
merge set handle remote
Specifying NetBIOS
Some DOS and Windows 3.1 applications specifically ask whether NetBIOS
support is available before they operate properly in a
network environment.
By default, Win4Lin responds yes when a DOS program asks whether NetBIOS support is available. Note that Win4Lin does not actually support NetBIOS; it only responds this way to the initial query from the application.
Although this default value does not adversely affect any tested applications, you might discover an application that does not behave as expected unless you change the default.
Type the following command at the DOS prompt to
change the default so that Win4Lin responds no to
inquiries about NetBIOS support:
merge set netbios off
To return to the Win4Lin default, type:
merge set netbios on
Specifying the Microsoft redirector
Some DOS and Windows 3.1 applications recognize the DOS interrupt 21H
system call function 5f02 (Get Redirector List Entry)
used by the Microsoft redirector.
By default, Win4Lin enables processing for this function.
Although this default value does not adversely affect any tested applications, you might discover an application that does not behave as expected unless you change the default.
Type the following command at the DOS prompt
to change the default so that Win4Lin does not recognize
the 5f02 function:
merge set 5f02 off
To return to the Win4Lin default, type:
merge set 5f02 on
Printing files with control characters
DOS normally opens character output devices, such as
printers, in character mode.
In character mode, DOS recognizes certain ASCII codes as instructions to DOS
or to the output device.
For example, DOS interprets the ASCII code for the Ctrl-Z
(^Z) combination as an
end-of-file instruction and stops processing the file at that point.
By default, Win4Lin opens character output devices, such as printers, in binary mode. In binary mode, DOS treats embedded control characters as ordinary characters and outputs them to the device just like any other character. That is, in binary mode, encountering a ^Z in a file does not cause DOS to halt printing.
To have Win4Lin open character devices in standard DOS
character mode instead of binary mode, type the
following at the DOS prompt:
merge set lpt_binary off
To return Win4Lin to the default of opening character
devices in binary mode, type:
merge set lpt_binary on
Displaying current settings
To display the current settings for any
merge command option, use the
display option.
For example, to see the current setting for
pollsleep, type the
following at the DOS prompt:
merge display pollsleep
To see the current settings for all the
merge command options, type:
merge display
Setting the DOS exit code
You can use the
merge return option to set the DOS
exit code to a numeric value (0 or 1) that
corresponds to the state of one of the other merge options.
The merge command assigns the value 1 to the on or remote condition and the value 0 to the off or local condition.
For example, suppose you want to determine the current
pollsleep setting.
Type the following:
merge return pollsleep
When the current value for pollsleep is on, the merge command sets the DOS exit code to 1. When the current value for pollsleep is off, the merge command sets the DOS exit code to 0.
You can create a DOS batch file, such as errlevel.bat, to check the exit code and take appropriate action. You can include the following lines in the batch file to determine whether pollsleep is on:
merge return pollsleep if errorlevel == 1 goto ISON echo POLLSLEEP is OFF goto END :ISON echo POLLSLEEP is ON :END
Win4Lin makes use of some X resources to configure Desktop features, mostly for color definitions. Procedures for administering X resources vary according to the X server installed on your system and are described in the documentation for your Desktop.
For a complete list of resources that Win4Lin uses, refer to the file /usr/X11R6/lib/X11/app-defaults/Win4Lin.