Module 85 machid (SV)

Previous Table of Contents Next


Module 85
machid (SV)

DESCRIPTION

The external machid commands return a true or false value. Machid is not a command itself but refers to a set of commands. These commands are used to identify the hardware you are using. They are usually used in shell scripts to provide portability. If the machid command you use has a return value of zero (0), you are using the hardware described by the command name . The following example is a typical shell script coding:

if vax # If on a vax computer,
then cd /usr/lib/vax # change directories to vax one
else cd /usr/lib/other # else change dir to other one
fi # end the if conditional.

COMMAND FORMAT

Following is the general format of each machid command.

pdp11 True if on a DEC PDP-11/45 or PDP-11/70 computer.
u3b True if on an AT&T 3B20 computer.
u3b2 True if on an AT&T 3B2 computer.
u3b5 True if on an AT&T 3B5 computer.
u3b15 True if on an AT&T 3B15 computer.
sun True if on a Sun Microsystems computer.
sun3 True if on a Sun model 3 computer.
sun4 True if on a Sun model 4 (SPARC ) computer.
vax True if on a DEC VAX-11/750 or VAX-11/780 computer.
u370 True if on an IBM System/370 computer.

NOTE:    
Not all vendors implement all of the commands. Usually the vendor only implements the more common hardware types and one for the vendor s own hardware.

RELATED COMMANDS

Refer to the test command described in Module 135.

RELATED FILES

The machid commands do no return output, they simply provide return codes.

RETURN CODES

The machid commands return a true (zero) value if you are on the type of machine the command describes. If you are NOT on the machine described by the command name, then a false (nonzero) value is returned.

APPLICATIONS

These commands are used in shell scripts to provide portability across different types of hardware. Shell scripts can be coded to handle different hardware device paths, different command formats, and various other system dependencies. The machid commands are useful in a make file to control how a program is compiled. In some cases the uname command, described in Module 148, can be used to perform the same task. If uname is used, the test command must be used to check for specific strings being returned.

TYPICAL OPERATION

In this activity you use the machid commands to display what type of system you are using. Begin at the shell prompt.

1.    Type in the following code at your shell prompt. As you enter new lines your secondary prompt (PS2) will be displayed. You may wish to use the whence command to see if your system supports any of the commands used in this activity.
 cj> for CMDTYPE in u3b2 u3b5 vax      do       if $CMDTYPE       then echo You are using a $CMDTYPE machine!       fi      done 

You may wish to add additional hardware names on the for line.
2.     Turn to Module 144 to continue the learning sequence.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net