S5 version Table of Contents (frame/ no frame)
(26) More on Shells Previous Top Next

More on shells

The Environment

The environment variables are a way to pass information to programs - any program can examine these strings and modify its behaviour (e.g. PRINTER is looked at by the lpr program. Some of these environment variables can be changed, others are preset by the system.

env
HOME=/classes/rcomp1
SHELL=/usr/local/bin/tcsh
TERM=vt100
USER=rcomp1
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/ucb:.
HOSTTYPE=sun4
VENDOR=sun
OSTYPE=solaris
MACHTYPE=sparc
SHLVL=1
PWD=/classes/rcomp1
LOGNAME=rcomp1
GROUP=users
HOST=sunray.dartmouth.edu
MANPATH=/usr/local/man:/usr/man:/usr/share/man
PRINTER=berry-public

Command Line Arguments

The other way information is passed to applications is through the command line arguments. Everything following the program name on the command line, except things interpreted directly by the shell, is made available to the program. Typically these are option flags (to modify the behaviour of the program) and filenames (for the program to act on). The program may then also have a direct interaction with the use via a text or graphical interface. Most program use all of the methods.

Many featuresof Unix are designed to help in automating procedures (Unix users are lazy). Passing information via the environment and the command line is scriptable, while direct interaction via the keyboard and mouse is not.

Job control

Shells also allow you to place jobs in the background and run multiple processes from one shell session, although multiple windows are easier for this.
ls -FCR > save_it &
The "&" says make this a background job.
^Z
control-Z sends a "suspend" signal to a currently running process
bg
continue execution of a suspended process in the background (must not try to read from the keyboard, but can write to the screen)
fg
resume execution of a suspended program in the foreground
jobs
list background jobs running in current shell session.

Previous Top Next


slide27.src  last modified Jan 31, 2011 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College