| Previous | Table of Contents | Next |
|
|
|---|
| C Shell |
| The following list describes the files the csh command uses. |
| standard input | Reads from the terminal keyboard or the output of a pipe. |
| standard output | Writes to the terminal screen or the input of a pipe. |
| standard error | Writes errors to the terminal screen or the input of a pipe. |
| ~/.cshrc | Executes the commands stored in this file at start of execution by each new shell. |
| ~/.login | Executes the commands stored in this file during login to set up user-defined environment. Executed after /etc/login. |
| ~/.logout | Executes the commands stored in this file at logout time. |
| /etc/login | Executes the commands stored in this file after ~/.cshrc. |
| /tmp/sh* | Temporary file used for the '<<' command. |
| /dev/null | The system trash can, used to dump unwanted output. |
| /etc/passwd | Used to find home directories for ~name substitutions. |
| /bin/ksh | Used to execute shell scripts that do not begin with a number sign (#) in row 1 column 1. |
|
|
|
RETURN CODES
The shell returns a nonzero exit code if an error is incurred during noninteractive execution (shell script execution). If the shell is being used interactively, then the exit code of the last command is returned. The value of the exit code is stored in the $? variable.
APPLICATIONS
There are two primary uses of the ksh program. The most common is using the shell as a command processor. Where ksh reads input from your terminal and processes it as commands. This is referred to as an interactive shell.
The second most common use of the shell is as a programming language. Using the shell as a programming language is beneficial. Shell scripts can be written to store multiple commands in a file. Programming constructs are provided to write a high level language type program. By using the shell, programming projects can be prototyped in a short time frame.
The shell provides a command environment. It is often desirable to change the environment variables for temporary use and then return to the original environment. Because the current shell passes the environment to all child processes, you can start another ksh to change your environment. Once the new shell is started you can change the environment, execute the desired commands, and then exit back to your original command processor (ksh). Your original environment exists just as you left it.
TYPICAL OPERATION
In this activity you use the ksh (csh) command as a command processor to enter commands from your terminal, an interactive programming language, and to create a new environment to execute commands. Begin at the shell prompt.
cj> env
LOGNAME=mylogin
MAIL=/usr/mail/mylogin
ENV=/u1/ts/mylogin/.kshrc
HOME=/u1/ts/mylogin
PATH=:/bin:/usr/lbin:/utils:/u1/ts/mylogin/bin:.
TZ=CST6CDT
TMPDIR=/tmp
VISUAL=vi
FCEDIT=vi
SHELL=/bin/ksh
|
|
|
|---|---|
| C Shell | |
| If you are using the csh use printenv. | |
|
|
|
cj> OIFS=$IFS # save IFS in OIFS to restore later
cj> IFS=":" # reset the internal field descriptor to colon
cj> cat db/phone | while read LINE
do
set - $LINE
echo "$1 \t $4 \t $5"
done
cj> IFS=$OIFS # restore the original IFS variable
|
|
|---|
| C Shell |
cj> set argv=( newarg1 newarg2 newargN )
|
|
|
|---|---|
| C Shell | |
| Type set home=/tmp. | |
|
|
|
|
|
|
|---|---|
| C Shell | |
| Type setenv VAR. | |
|
|
|
|
|
|
|---|---|
| C Shell | |
| Type printenv. | |
|
|
|
|
|
|
|---|---|
| C Shell | |
| Type printenv. | |
|
|
|
| Previous | Table of Contents | Next |