This documentation refers to a previously released version of BMC Discovery.
See the information on this topic for the latest version (11.3) or version 11.2.

Screen is a utility which enables you to access multiple virtual terminals from a single terminal. For example, you can connect to the BMC Discovery appliance using a single terminal emulator, start screen, create multiple virtual terminals, and use one to start a long running process such as upgrading the appliance and another to tail the output log. Screen provides the additional advantage that should the connection be dropped, you can re-connect to the appliance, and re-attach to screen where the processes are still running, unaffected by the dropped connection.

Running screen

The following commands enable you to start screen and to reattach to an existing session. Screen offers many more command line options, but these are beyond the scope of this tutorial. See further information to find out more about screen.

Command

Description

screen

Start screen.

screen -ls

List existing screen sessions. Used after detaching or after a dropped connection. Example output showing two screen sessions:

[tideway@appliance01 ~]$ screen -ls
There are screens on:
        2970.pts-0.appliance01   (Detached)
        3078.pts-0.appliance01   (Detached)
2 Sockets in /var/run/screen/S-tideway.

[tideway@appliance01 ~]$

screen -r

Reattach to a detached screen session. If there are multiple screen sessions listed, add the session to which you want to connect.

[tideway@appliance01 ~]$ screen -r 2970.pts-0.appliance01

Working with screen

When screen is running, you can run commands in the terminal as usual. To interact with screen you begin all commands with:
CTRL+a
That is, the Control key and the a key pressed at the same time. Then an additional key completes the command.

The following table shows some of the more common screen commands. For complete information on the commands available in screen, consult the man page.

Command

Description

CTRL+a c

Create a new screen virtual terminal.

CTRL+a n

Switch to the next virtual terminal.

CTRL+a p

Switch to the previous virtual terminal.

CTRL+a d

Detach the current terminal from the screen session. The screen utility continues to run and all virtual terminals and processes continue to run. You can reattach using the screen -r command described above.

CTRL+a A

Rename the virtual terminal. An example is given below.

To close a virtual terminal, exit all running programs and then type exit to close the terminal.

Exiting screen

The following command exits the screen utility. This is not the same as detaching. When you exit screen, the utility stops. You can only do this when you have closed all your running programs.

Command

Description

CRTL+D

Exit screen. You can also exit screen when you have closed all but one virtual terminal by typing exit in the remaining virtual terminal.

Example screen usage

The following example shows how you can use screen when upgrading the appliance to run the upgrade and monitor its progress. It also shows how to detach and reattach screen "windows" or virtual terminals.

This example procedure does not tell you how to upgrade the appliance, that is covered here.

Using screen when upgrading the appliance

  1. Login to the appliance command line interface as the tideway user.
  2. Run the screen utility. Enter:

    [tideway@appliance01 ~]$ screen

    You are presented with a welcome information screen. Press the Enter key to dismiss this.

  3. Rename the virtual terminal to "twuser". Enter:
    CTRL+a A
    At the bottom of the terminal window highlighted text prompts you to Set window's title to:. Enter:

    Set window's title to: twuser
  4. Create a new virtual terminal. Enter:
    CTRL+a c
  5. Become the root user. Enter the su command and the root password when prompted:

    [tideway@appliance01 ~]$ su
    Password:
    [root@appliance01 ~]#
  6. Rename the virtual terminal to "twroot". Enter:
    CTRL+a A
    At the bottom of the terminal window highlighted text prompts you to Set window's title to:. Enter:

    Set window's title to: twroot
  7. Start the upgrade procedure. The following command shows running the script:

    [root@appliance01 ~]# sh ADDM_Upgrade_64_Vnnnnn_nnnnnn_dev.sh

    A welcome to the upgrade banner is displayed.

  8. Once the script is running, switch to the first (twuser) virtual terminal. Enter:
    CTRL+a p
    The tideway user prompt is displayed.

    [tideway@appliance01 ~]$ 
  9. Upgrading the OS and the BMC Discovery application can take a long time. Monitor progress by checking the log file using the following command:

    [tideway@appliance01 ~]$ tail -f /usr/tideway/log/upgrade_V.n.log
  10. Switch back to the twroot virtual terminal. Enter:
    CTRL+a n
    The upgrade is progressing:

    ---------------------------------------------------------------
    STAGE 2: Upgrade Operating System
    ---------------------------------------------------------------
    Running Operating System upgrade...
    Running OS upgrade script
    Operating system upgrade complete.
  11. Switch back to the twuser virtual terminal. Enter:
    CTRL+a n
    The upgrade log is displayed:

    2012-08-02 12:44:39: Move new IPv6 firewall configuration into place
    2012-08-02 12:44:39: Ensure correct perms are set on the IPv6 firewall configuration
    2012-08-02 12:44:39: Add appliance, omniNames and tideway services
    2012-08-02 12:44:39: Set omniNames and httpd to run on runlevel 3
  12. Someone from IT comes and tells you that they need to reboot your PC immediately. You then detach your terminal from the screen session before rebooting. Enter:
    CTRL+a d
  13. Close the terminal window. Enter:

    [tideway@appliance01 ~]$ exit

    and reboot the PC.

  14. Once the PC is running again, login to the appliance command line interface as the tideway user.
  15. Reattach to the screen session. Enter:

    [tideway@appliance01 ~]$ screen -r

    Screen reconnects to the existing session and you can see how the upgrade is progressing in the twroot virtual terminal, and see the tailed log in the twuser virtual terminal. More information on reattaching is provided below.

The procedure above has demonstrated using screen with two named virtual terminals.

Recovering from a lost connection using screen

If you lose the connection to the appliance and you have used screen, you can reconnect to the appliance and recover the virtual terminal running the compaction. To do this:

  1. Reconnect to the appliance and login as the tideway user.
  2. List the current screen sessions. Enter:

    [tideway@appliance01 ~]$ screen -ls
    There is a screen on:
            23274.pts-0.appliance01        (Detached)
    1 Socket in /var/run/screen/S-tideway.
    

    If there is only one screen listed, you can re-attach to it with a simple command:

    [tideway@appliance01 ~]$ screen -r

    If there is more than one, copy the screen identifier:

    [tideway@appliance01 ~]$ screen -r 23274.pts-0.appliance01

    All of the virtual terminals are recovered and you can see how the upgrade is progressing.

Further information

This section lists some useful resources for screen.

Was this page helpful? Yes No Submitting... Thank you
  • No labels
© Copyright 2004 - 2018 BMC Software, Inc.
Legal notices