Introduction to the C-Shell

Discussion in 'Programming' started by CSAspie, Aug 13, 2010.

  1. #1
    These features are added to the standard features in the C Shell:
    • Several ways to set and access variables
    • Built-in programming language that supports conditional branching, looping and interrupt handling
    • Command customization using aliases
    • Access to previous commands via a history mechanism
    • Advanced job control
    • New built-in commands and several enhancements to existing commands

    Filename Completion:
    To turn on this function, you need to set the ' filec ' variable.
    % set filec
    Pressing [esc] will auto-complete, but if multiple variables are possible press [esc] + *

    Aliases:
    where word is your wanted command, and string is the existing command
    Code:
    % alias [word[string]]

    History:
    ' ! ' allows you to access the history.
    The up-arrow will take you to the last command, and the down-arrow will return.
    To set the size of the history to be saved:
    Code:
    $HISTFILE: 2 ; set history = 40
    where 40 is the size of the history to be kept.

    Execution Order:
    • Quotation marks
    • Alias substitution
    • I/O redirection, pipes, background execution
    • Variable substitution
    • Command Execution


    User Services usually provided include:
    • Loading and execution of program files
    • Retrieval, storage, and manipulation of files
    • User I/O Services, in the form of disk commands, printer spooling and others
    • Security and data integrity protection
    • Inter-user communication and shared data and programs, on multi-user and networked systems
    • Information about the status of the system and its files
    • I/O and file services plus other specialized services for user programs

    User Interface Types:
    • CLI - Command Line Interface, typed instructions are interpreted and executed
    • MDI - Menu-Driven Interface, All commands are stored in a menu, usually nested in sub-menu's
    • GUI - Graphic User Interface, most commonly used today
    • Voice Activated UI
    • Web Form UI

    Introduction to Unix shells:
    A shell sits between the user and the operating system, acting as an interpreter. An interpreter operates in a simple loop:
    while(running){
    display prompt;
    accept command;
    interpret command;
    execute command;
    }

    Each command consists of:
    • Command name
    • Command options
    • Command arguments
    Separated by blank spaces.

    Types of Shell:
    • Bourne Shell - /bin/sh
    • Korn Shell - /bin/ksh
    • C Shell - /bin/csh

    Shell Start-up:
    • Read a start-up file
    • Display prompt and wait for user command
    • Unless '^D' is typed, then returns to prompt, else the shell terminates.

    Pipes:
    Pipeline supports one of the basic UNIX philosophies, which is that large problems can often be solved by a chain of smaller processes, each performed by a relatively small, reusable utility.
    To use a command as standard input to another, run the first command ending it with a ' | ' followed by the command to feed the output of the first command to.

    Sequences:
    Entering a series of commands separated by ' ; ' will be run left to right, extending onto the next line can be done by typing \ before enter.

    Grouping Commands:
    Placing brackets around a sequence of commands will redirect all their output, in order left to right, into the output requested (e.g. save to a file).
    The group will be executed in a sub-shell pipelining the output back to the current user shell.

    Conditional Sequences:
    All built-in shell commands return 0 on successful completion, and 1 on fault. Using this a user can construct sequences.
    ' && ' separating the commands will run the second command only if the left command executes without error.
    ' || ' separating the commands will run the second command only if the left command fails.

    Subshell Uses:
    • Grouped Command - if not run in background then the parent sleeps until the child completes
    • Script Execution - if the script is not run in the background, the parent shell sleeps until the child shell terminates
    • Background Job - parent continues to run concurrently with the child shell
     
    CSAspie, Aug 13, 2010 IP