Archive for February, 2008

Now that you have looked at using the (Crystaltech web hosting)

Friday, February 1st, 2008

Now that you have looked at using the uname command to gather information about the version of UNIX that is being used, you need a method for using this information in a shell script. As you saw in Chapter 21, “Problem Solving With Functions,” creating a shell function that determines the version of UNIX gives the greatest flexibility. A shell function that returns the operating system type is as follows: getOSName() { case uname -s in *BSD) echo bsd ;; SunOS) case uname -r in 5.*) echo solaris ;; *) echo sunos ;; esac ;; Linux) echo linux ;; HP-UX) echo hpux ;; AIX) echo aix ;; *) echo unknown ;; esac } As you can see, this function is not very complicated. It checks the output of uname -s and looks for a match. In the case of SunOS, it also checks the output of uname -r to determine whether the operating system is Solaris or SunOS. In many cases, you need to tailor the options of a command, such as ps or df, so that the command can generate the desired output. In such cases, you need the capability to “ask” whether the operating system is of a certain type. A shell function that performs this task follows: isOS() { if [ $# -lt 1 ] ; then echo “ERROR: Insufficient Aruments.” >&2 return 1 fi REQ= echo $1 | tr ‘[A-Z]’ ‘[a-z]’ if [ “$REQ” = ” getOSName ” ] ; then return 0 ; fi return 1 } This function compares its first argument to the output of the function getOSName and returns 0 (true) if they are the same; otherwise, it returns 1 (false). Using this function, you write if statements of the following type: if isOS hpux ; then
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

following output: SunOS 4.1.3 (Geocities web hosting) Determining the Hardware Type

Friday, February 1st, 2008

following output: SunOS 4.1.3 Determining the Hardware Type Sometimes a shell script is written as a wrapper around a hardware-specific program. For example, install scripts are usually the same for different hardware platforms supported by a particular operating system. Although the install script might be the same for every hardware platform, the files that are installed are usually different. To determine the hardware type, use the -m option of the uname command: $ uname -m sun4m Some common return values and their hardware types are given in Table 23.3. Table 23.3 Hardware Types Returned by the uname Command Hardware Description 9000/xxx Hewlett-Packard 9000 series workstation. Some common values of xxx are 700, 712, 715, and 750. i386 Intel 386-, 486-, Pentium-, or Pentium II-based workstation. sun4x A Sun Microsystems workstation. Some common values of x are c (SparcStation 1 and 2), m (SparcStation 10 and 20), and u (UltraSparc). alpha A workstation based on the Digital Electronics Corporation ALPHA microprocessor. Determining the hostname of a System Many shell scripts need to check the hostname of a system. The traditional method of doing this on BSD systems is to use the hostname command, as in the following example: $ hostname soda.CSUA.Berkeley.EDU In System V, the hostname command is not always available. The uname -n command is used instead: $ uname -n kashi Because the uname -n command is available on both System V and BSD UNIX, it is preferred for use in portable shell scripts. Determining the UNIX Version Using a Function
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.