10.1. Introduction

An interactive shell is one in which the standard input, output, and errors are connected to a terminal. When using the TC shell (tcsh) interactively, you will be typing commands at the tcsh prompt and waiting for a response. The TC[1] shell is a program that starts up at login time and interprets commands. It is a public domain enhanced version of its predecessor, the Berkeley UNIX C shell. Additional features include command line editing, fancy prompts, programmable completions (filenames, commands, and variables), spelling correction, etc.

[1] The T in tcsh has historical origins dating back to the TENEX and TOP-10s operating systems used by DEC for its PDP-10 computer. These systems had a form of command completion for the monitor. The creator of the tcsh admired features of these systems, and hence, added the T to the C shell.

The primary tcsh source distribution is at ftp.astron.com, also ftp.gw.com, and ftp.primate.wisc.edu.[2] Although tcsh is included in most Linux distributions, it can be ported to a number of operating systems, including Solaris, Windows NT, HP-UX, QNX, etc.

[2] See tutorial at www.tac.nyc.ny.us/mirrors/tcsh-book.

This chapter focuses on how to use the TC shell interactively and how to set up your initial working environment. The next chapter will guide you through the programming constructs provided with the TC shell for writing script files. Then, instead of typing commands at the prompt, you will be storing them in a file and executing the file.

10.1.1. Versions of tcsh

To find out what version of tcsh you are using, type at the shell prompt:

which tcsh

To tell you in what directory tcsh is installed (normally /bin), and to print the version information, type:

/directory_path/tcsh -c 'echo $version'

Example 10.1.
1  which tcsh
						/bin/tcsh
2  /bin/tcsh -c 'echo $version'
						tcsh 6.07.09 (Astron) 1998-07-07 (i386-intel-linux) options
						8b,nls,dl,al,rh,color
					

10.1.2. Startup

Before the TC shell displays a prompt, it is preceded by a number of processes. See Figure 10.1.

Figure 10.1. System startup and the TC shell


After the system boots, the first process to run is called init, process identification number (PID) 1. It spawns a getty process. These processes are responsible for opening up the terminal ports, for providing a place where input comes from (stdin) and where standard output (stdout) and error (stderr) go, and for putting a login prompt on your screen. After the user types his user name, the /bin/login program is executed. The login program prompts for a password, encrypts and verifies your password, sets up an initial working environment, and then initiates the shell, /bin/tcsh. The TC shell looks in the /etc directory for a system startup file called /etc/csh.cshrc and /etc/csh.login (if it exists). It then looks in the user's home directory for a file called ~/.tcshrc, another initialization file used to customize the tcsh environment. If that file is not found, it will look for another file that does the same job, called ~/.cshrc (normally invoked when running csh). After executing commands in the .tcshrc file (or .cshrc), it will execute the history file, commonly called .history. Then commands in the ~/.login file are executed, and finally the .cshdirs file is executed. Each of these files will be explained in "The Environment" below. [3]

[3] The order in which these files are read can be changed when tcsh is compiled.

The /etc/csh.cshrc and ~/.tcshrc files will be executed every time a new TC shell is started. The .login file is executed only once when the user logs on, and also contains commands and variables to initialize the user's environment. After executing commands from all the startup files, the prompt (> is the default) appears on your screen and the tcsh awaits commands. See Figure 10.2.

Figure 10.2. If any of these initialization files exist, they are sourced in this sequence


When logging out, the user presses Control-D or will be automatically logged out if the autologout shell variable has been set. Before logging off, the shell looks for a file called /etc/csh.logout or ~/.logout in the home directory and if either is located, its commands will be executed. The .logout file normally contains commands to clean up temporary files, append data to logfiles, wish the user a good day, etc.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.206.69