Use > Server Automation > SA Global Shell > Global Shell tutorial

Global Shell tutorial

This tutorial covers just a few of the highlights of the OGFS and the Global Shell. After completing this tutorial, you will know how to navigate the directories of the OGFS and how to run commands on managed servers from within the Global Shell. Although the tutorial is organized into steps, after performing step 1, you can perform the remaining steps in any order.

Before starting the tutorial, you need the following capabilities:

  • You can log on to the SA Client. As you work through this tutorial, you might find it helpful to compare the stdout of the Global Shell with information displayed by the SA Client.
  • Your SA user has Read & Write permissions on at least one managed server. Typically assigned by a security administrator, permissions are discussed in the SA 10.51 Administer section.
  • Your SA user has all Global Shell permissions on the same managed server. For information on these permissions, see aaa utility.

The example commands in this tutorial operate on a Windows server named abc.opsware.com. This server belongs to a device group named All Windows Servers. When trying out these commands, substitute abc.opsware.com with the host name of the managed server you have permission to access. Also, replace jdoe with your SA user name. If you wish to run the commands on a UNIX managed server, replace ipconfig with ifconfig; and replace Administrator with root.

Now, let’s get started with the tutorial:

  1. Open a Global Shell session.

    You can open a Global Shell session from within the SA Client. From the Tools menu, select Global Shell. You can also open a Global Shell session from a terminal client running on your desk top. For instructions, see Open a Global Shell session.
  2. Check your session.

    First, enter the whoami command, which displays the SA user name for this session:

    $ whoami
    jdoe


    You can enter the ps command to view the process status of your Global Shell session. The following ps command shows the session is running the default bash shell:

    $ ps
    PID TTY TIME CMD
    7033 ? 00:00:00 bash
    13712 ? 00:00:00 ps


    Enter the uname command, which displays information about the server running the OGFS component of SA:

    $ uname -a
    Linux m171.dev.opsware.com 2.4.21-32.ELsmp #1 SMP Fri Apr 15 21:17:59 EDT 20 05 i686 GNU/Linux


    If you log on to a UNIX managed server with rosh, uname displays information about that managed server, not the server running the OGFS component. Run the uname command when you are not sure if you are interacting with the Global Shell or with the shell of a managed server accessed with rosh.
  3. Confirm your home directory.

    Every SA user has a home directory in the OGFS. The home directory has a public/bin subdirectory where you can store scripts to be executed by other users running Global Shell sessions. Each SA user also has a personal /tmp directory for temporary files. You cannot view or modify the /tmp directories of other users.

    The following commands show some information about the directories of the jdoe user:

    $ cd
    $ pwd
    /home/jdoe
    $ ls -ld /home/jdoe/public/bin
    drwxr-xr-x 2 jdoe jdoe 4096 2006-05-17 17:12 /home/jdoe/
    public/bin
    $ ls -ld /tmp
    drwxrwxrwx 3 root root 4096 2006-06-09 23:37 /tmp
  4. List all managed servers.

    The /opsw/Server directory of the OGFS contains information about the servers managed by SA. This directory is an example of how the OGFS represents objects (in this case servers) of the SAdata model. Behind the scenes, SA stores this information in a database referred to as the Model Repository.

    To view the names of the servers managed by SA, enter the following command:

    $ ls /opsw/Server/@
    abc.ospware.com      m33.opsware.com        gist.opsware.com pal.opsware.com      hare.opsware.com       qv55.opsware.com
    . . .
  5. Examine server information.

    Each managed server has a directory structure containing information about that server. The attr subdirectory contains text files that describe the server’s attributes. The attribute name matches the file name and the attribute value is the file contents. The following cat command lists the OS version of the managed server named abc.opsware.com:

    $ cd /opsw/Server/@/abc.opsware.com
    $ cat attr/osVersion


    Microsoft Windows 2000 Advanced Server Service Pack 4 Build 2195 (05-02-2006

    The Interface subdirectory has information about the server’s network interfaces. Here’s an example:

    $ cat “Interface/Local Area Connection/info”
    AdminEnabledFlg: no
    CardIndex:
    CardSerialNum:
    CircuitId:
    Collisions:
    ConfiguredDuplex: AUTO
    ConfiguredSpeed: AUTO

    . . .
  6. List the files of a managed server.

    In addition to information about managed servers, /opsw/Server contains directories that correspond to the file systems of those servers. If you have the necessary permissions, in a Global Shell session you can access multiple servers from a single virtual file system, the OGFS.

    The following command navigates to file system of the abc.opsware.com server:

    $ cd /opsw/Server/@/abc.opsware.com/files

    The next ls command displays OGFS subdirectories that correspond to native users of the managed server. Your security administrator specified these users (login names) when adding OGFS permissions. These are not SA users.

    $ ls

    Administrator LocalSystem
    Native users might have different views of the managed server’s file system. Therefore, under each user, the OGFS presents different file systems for each user. The following cd command drills down to the Program Files directory as seen by the Administrator user on the Windows server.

    $ cd "Administrator/C/Program Files"
    $ pwd
    /opsw/Server/@/abc.opsware.com/files/Administrator/C/Program Files


    Next, list the files in the Program Files directory:

    $ ls -1

    Accessories
    Common Files
    ComPlus Applications
    Internet Explorer
    Messenger

    . . .

    Although these files reside in a directory on the managed server’s file system, you are in the OGFS, as shown by the preceding pwd command. To verify that you are in a Global Shell session (and not in a session running on the managed server), enter the following commands:

    $ whoami jdoe
    $ uname -a
    Linux m171.dev.opsware.com 2.4.21-32.ELsmp #1 SMP Fri Apr 15 21:17:59 EDT 2005 i686 GNU/Linux
  7. Copy a file from the OGFS to a managed server.

    By entering the cd command, go to your home directory in the OGFS, for example:
    $ cd
    $ pwd
    /home/jdoe


    Next, create a simple text file in your home directory:

    $ echo “this is text” > myfile.txt
    $ cat myfile.txt


    this is text

    Copy the file that you just created to a directory in the file system of a managed server. The following command copies myfile.txt to the C:\temp directory of the abc.opsware.com server:

    $ cp myfile.txt \
    /opsw/Server/@/abc.opsware.com\
    /files/Administrator/C/temp/afile.txt


    Do not copy large files between the OGFS and managed servers. Copy only small files, such as configuration files.
  8. Log on to a managed server with rosh.

    In the preceding steps, you accessed the file system of a managed server from within a Global Shell session. In this step, from the Global Shell you log on to a managed server with rosh. After you log in, you interact with the command-line environment (MSDOS or UNIX shell) of the managed server.

    The following rosh command logs in as Administrator to a Windows managed server named abc.opsware.com:

    $ cd /opsw/Server/@/abc.opsware.com
    $ rosh -l Administrator
    Microsoft Windows 2000 [Version 5.00.2195]
    (C) Copyright 1985-2000 Microsoft Corp.


    The prompt indicates that you are now in the command-line environment of the managed server. Enter the ipconfig and hostname commands:

    C:\WINNT\system32>ipconfig
    ipconfig


    Windows 2000 IP Configuration

    Ethernet adapter Local Area Connection:

    Connection-specific DNS Suffix . : opsware.com
    IP Address. . . . . . . . . . . . : 192.168.8.217
    Subnet Mask . . . . . . . . . . . : 255.255.254.0
    Default Gateway . . . . . . . . . : 192.168.8.1
    C:\WINNT\system32>hostname
    hostname
    abc

    Terminate the remote login with the exit command:
    C:\WINNT\system32>exit

    Enter the uname command to verify that you have returned to the Global Shell session:
    $ uname -a

    Linux m171.dev.opsware.com 2.4.21-32.ELsmp #1 SMP Fri Apr 15 21:17:59 EDT 2005 i686 GNU/Linux
  9. Create a script that runs across servers.

    A Global Shell script can iterate within the OGFS and run the rosh command to execute native commands on multiple servers. The example script shown in this step iterates through the servers of the public device group named All Windows Servers. On each server, the script runs the ipconfig command with the rosh command. In this example, substitute your SA user name for jdoe.

    First, return to your home directory in the OGFS:
    $ cd
    $ cd public/bin
    $ pwd
    /home/jdoe/public/bin


    Next, run the vi editor:
    $ vi

    In vi, insert the following lines to create a bash script:

    #!/bin/bash
    # This is simple_iterate.sh.
    # Change jdoe to your user name.


    OUTFILE="/home/jdoe/public/bin/ipconfig_all.txt"
    rm -f $OUTFILE

    cd "/opsw/Group/Public/All Windows Servers/@/Server"

    for SERVER_NAME in *
    do
    echo ---- $SERVER_NAME
    echo ---- $SERVER_NAME >> $OUTFILE
    rosh -n $SERVER_NAME -l Administrator \
               "ipconfig" >> $OUTFILE

    done
    # Last line in simple_iterate.sh.


    Save the file in vi, naming it simple_iterate.sh. Quit vi.

    Change the permissions of simple_iterate.sh with chmod, and then run it:

    $ chmod 755 simple_iterate.sh
    $ ./simple_iterate.sh
    ---- abc.ospware.com
    ---- gist.opsware.com
    ---- hare.opsware.com
    ---- m33.opsware.com
    . . .


    As the script runs, it echoes the name of each server to stdout, and redirects the output of the ipconfig command to the ipconfig_all.txt file. Enter the more command to view the contents of ipconfig_all.txt:

    $ more ipconfig_all.txt
    ---- abc.ospware.com
    Windows 2000 IP Configuration
    Ethernet adapter Local Area Connection: . . .
  10. Learn more.
    Here are a few suggested tasks for learning more about the OGFS and the Global Shell:
    • Explore the folders and contents under /opsw/Library, comparing them with the Library windows of the SA Client.
    • If you have NA installed, navigate to the /opsw/Net* (network) directories. For descriptions of these directories, see Network directories.
    • On Windows servers, examine the registry and complus directories under
      /opsw/Server/@/server-name.
    • List the files in the method directory, also under /opsw/Server/@/server-name. These files are the executables of the SA Command-Line Interface (OCLI), which enables you to perform SA functions from within the Global Shell. To learn how to run the CLI methods, see the SA 10.51 Developer section.