home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 12.8 Job Control in a Nutshell Chapter 12
Job Control
Next: 13. Redirecting Input and Output
 

12.9 Running Multiple Shell Sessions with screen

screen
An interesting alternative to job control ( 12.1 ) is the screen program, which lets you run several shell sessions from the same terminal, switching between them at will.

For example, often when I'm logged in I want to reply to a mail message ( 1.33 ) but I need to test something first. Currently, I have to get out of mail to do it, or start a shell escape ( 30.26 ) within mail . But using the screen program, I could just switch back and forth between shells. I could run mail in one shell, test things in another, edit a file in a third, etc.-up to 10 shells in all. (If you run Linux, you can choose from eight virtual consoles by using the [ALT] key with one of the keys [F1] through [F8] . But that still doesn't have all the nice features of screen .)

Once you start up screen , a full screen disclaimer appears (which can be disabled by configuring $HOME/.screenrc ). After pressing SPACE or RETURN, you'll be placed in an initial shell with your usual system prompt. This shell is screen number 0.

Screen 0

I can use this shell to read my mail.

lmui@ruby 26% 

mail


Mail version SMI 4.0 Wed Oct 23 10:38:28 PDT 1991  Type ? for help.
"/usr/spool/mail/lmui": 42 messages 6 new
   ...
 N 38 kramer   Wed Oct 28 10:31   20/654   Posting on comp.unix.que

 N 39 tim      Wed Oct 28 10:46   39/1485  Re: awf
 N 40 tim      Wed Oct 28 10:47   26/832   Re: announcement of vol8
&

Now, suppose I read a mail message asking my opinion about a news posting. Rather than get out of mail to read news before I respond, I can just start a new shell using CTRL-a CTRL-c and start up a news reader there. This new window is screen number 1.

Screen 1

lmui@ruby 26% 

rn comp.unix.questions


Unread news in comp.unix.questions                    333 articles

******** 333 unread articles in comp.unix.questions-read now? [ynq]

Once I read the article in question, I switch back to the previous shell using CTRL-a CTRL-a and start to respond to the mail message:

Screen 0

>  38 kramer    Wed Oct 28 10:31   20/654   Posting on comp.unix.que
 N 39 tim       Wed Oct 28 10:46   39/1485  Re: awf
 N 40 tim       Wed Oct 28 10:47   26/832   Re: announcement of vol8
& 

r


To: kramer@ora.com
Subject: Re: Posting on comp.unix.questions



He's right that you can use -i for interactive prompting, but 
I don't think -f disables interactive mode.

Now, suppose I want to check my facts before I continue writing the message. Rather than quit my message or start a subshell, I can just start up yet another shell window by pressing CTRL-a CTRL-c again. Then I can run the commands I want to test. Once I have my information, I can go back to the previous shell using CTRL-a CTRL-a again, or using CTRL-a 0 to explicitly call up screen number 0.

One of the really neat things about screen is that it even lets you "detach" a screen, so that you can log out, then go home and pick up where you left off, using a different terminal ( 3.7 ) .

- LM


Previous: 12.8 Job Control in a Nutshell UNIX Power Tools Next: 13. Redirecting Input and Output
12.8 Job Control in a Nutshell Book Index 13. Redirecting Input and Output

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru