introduction to unix shell scripting with csh tcsh l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to Unix Shell & Scripting with csh / tcsh PowerPoint Presentation
Download Presentation
Introduction to Unix Shell & Scripting with csh / tcsh

Loading in 2 Seconds...

play fullscreen
1 / 19

Introduction to Unix Shell & Scripting with csh / tcsh - PowerPoint PPT Presentation


  • 208 Views
  • Uploaded on

Introduction to Unix Shell & Scripting with csh / tcsh. Brief Unix History Unix Shell & Flavor CSH/TCSH Scripts. Unix Architecture. What is Shell?. Shell is Command Interpreter that turns text that you type (at the command line) in to actions: User Interface: take the command from user

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Introduction to Unix Shell & Scripting with csh / tcsh' - Mercy


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction to unix shell scripting with csh tcsh

Introduction to Unix Shell & Scripting with csh/tcsh

Brief Unix History

Unix Shell & Flavor

CSH/TCSH Scripts

what is shell
What is Shell?
  • Shell is
    • Command Interpreter that turns text that you type (at the command line) in to actions:
    • User Interface: take the command from user
  • Programming Shell can do
    • Customization of a Unix session
    • Scripting
types of shells
Types of Shells
  • Interactive vs. Non-interactive; login or not
  • Interactive login shell started after login
  • Non-interactive shell
    • Present when shell script is running
    • Just inherits parent’s environment
  • Interactive non-login shell started
    • Started from a command line
    • Copies parent environment then invokes ~/.bash_rc (or ~/.cshrc or ~/.tcshrc)
popular shells
Popular Shells
  • sh Bourne Shell
  • ksh Korn Shell
  • csh,tcsh C Shell (for this course)
  • bash Bourne-Again Shell
flavors of unix shells
Flavors of Unix Shells
  • Two main flavors of Unix Shells
    • Bourne (or Standard Shell): sh, ksh, bash, zsh
      • Fast
      • $ for command prompt
    • C shell : csh, tcsh
      • better for user customization and scripting
      • %, > for command prompt
  • To check shell:
    • % echo $SHELL (shell is a pre-defined variable)
  • To switch shell:
    • % exec shellname (e.g., % exec bash)
startup files
Startup files
  • sh,ksh:

/etc/profile (out-of-the-box login shell settings)/etc/profile.local (addtnl. local system settings)~/.profile (addtnl. user customized settings)~/.kcshrc (non-login shell user customization)

  • bash:/etc/profile (out-of-the-box login shell settings) /etc/bash.bashrc (out-of-box non-login settings)/etc/bash.bashrc.local (global non-login settings)

~/.bash_profile (login shell user customization)

~/.bashrc (non-login shell user customization)

~/.bash_logout (user exits from interactive login shell)

  • csh/tcsh:/etc/login (out-of-the-box login shell settings)/etc/csh.login (non-login shell customizations)/etc/csh.login.local (global non-login settings)

~/.login: (login shell user customizations)

~/.cshrc: (non-login shell user customizations)

~/.cshrc.logout: (non-login shells at logout)

~/.logout: (read by login shells at logout)

some special keys under tcsh
Some Special Keys Under tcsh
  • Ctrl-U = Delete everything on the command-line
  • Ctrl-A = Move cursor to the front
  • Ctrl-E = Move cursor to the end
  • Ctrl-P = Set the current command-line to the previous command
  • Ctrl-N = Set the current command-line to the next command
  • TAB = Filename completion
what shell am i running
What shell am I running?

Use the echo command to learn the value of SHELL environment variable

Issue a ps command to see all the processes in your currentlogin session

what about my default shell
What about my default shell?

Use the echo command to learn the value of your default shell

Use the finger command to learn anyone’s default shell

View the /etc/passwd file to learn login shells and more

Use the grep command to search for a string in a file

To change the your default shell, e-mail the systems administrator (e.g., root@willow.olemiss.edu) and specifythe name of the shell that you want.

its not too late to change your current shell
Its Not Too Late to Change Your Current Shell

Use exec<shell name> to switch to a different shell

Issue a ps command to see all the processes in your currentlogin session

more with processes
More with processes

Issue a ps command to see all the processes in your currentlogin session

Issue a ps –u $USER command to see all your processes, across all login sessions

Use kill to terminate processes that have gone “rogue”

more with processes13
More with processes

Issue a ps -aef command to everyone’s processes

Pipe ps out put to more command to view page at a time

environment variables
Environment Variables

Use the env command to see all environment variables set to see all shell variables

http://docs.hp.com/en/B2355-90046/ch10s04.html

Set or change environment variables from the command-line:new values last only for current login session.

sh/bash/ksh set: NEW_VARIABLE=newvalue append: OLD_VARIABLE=$OLD_VARIABLEnewvalue prepend: OLD_VARIABLE=newvalue$OLD_VARIABLE

csh/tcsh set: set NEW_VAR=newvalue

append: set OLD_VAR=($OLD_VAR newvalue)

prepend: set OLD_VAR=(newvalue $OLD_VAR)

set: setenv OLD_VAR newvalue

append: setenv OLD_VAR ${OLD_VAR}newvalue

prepend: setenv OLD_VAR newvalue${OLD_VAR}

practice setting env variables
Practice Setting Env. Variables

Change the PROMPT environment variable

Update the PATH environment variable to include your numbered subdirectory

aliases
Aliases

Use the alias command to create shorthand for longer commands

command history
Command History

Your most recent commands are logged in one or more hidden files, which you may browse to keep from having to retypecommands.

You can set environment variables to configure how many commands are remembered in the current login session (history), how many commands are remembered after you logout (savehist), and the name of the file where thesecommands are stored (.history).

You can browse history commands from the command line.

customization of a session
Customization of a Session
  • Each shell supports some customization.
    • User prompt
    • Where to find mail
    • Shortcuts (alias)
  • The customization takes place in startup files
    • Startup files are read by the shell when it starts up
    • The Startup files can differ for different shell
examine startup files
Examine Startup files
  • sh,ksh:

/etc/profile (out-of-the-box login shell settings)/etc/profile.local (addtnl. local system settings)~/.profile (addtnl. user customized settings)~/.kcshrc (non-login shell user customization)

  • bash:/etc/profile (out-of-the-box login shell settings) /etc/bash.bashrc (out-of-box non-login settings)/etc/bash.bashrc.local (global non-login settings)

~/.bash_profile (login shell user customization)

~/.bashrc (non-login shell user customization)

~/.bash_logout (user exits from interactive login shell)

  • csh/tcsh:/etc/login (out-of-the-box login shell settings)/etc/csh.login (non-login shell customizations)/etc/csh.login.local (global non-login settings)

~/.login: (login shell user customizations)

~/.cshrc: (non-login shell user customizations)

~/.cshrc.logout: (non-login shells at logout)

~/.logout: (read by login shells at logout)