| Basic components
|
Example #1 patron-update
|
Example #2 bk-vygr-dl0
|
Script Interpreter - The first line of the script determines which shell or program will interpret the program.
|
First Line |
Interpreter |
|
#!/bin/sh |
Bourne shell |
|
#!/bin/ksh |
Korn shell |
|
#!/bin/csh -f |
C shell |
|
#!/usr/local/bin/perl -w |
Perl |
Commands - These can be native Unix commands, Voyager batch jobs, or anything else that runs on the command line.
Comments - The pound sign, "#" and anything following it, is treated as a comment and is not interpreted.
Exit status - Zero means "OK". One or greater indicates an error.
|
patron-update1
|
bk-vygr-dl01
|
| Some programming tools
|
Example #1 patron-update
|
Example #2 bk-vygr-dl0
|
Command substitution - When the output of a command is substituted in its place in the command line. Delimited by back quotes. See log-trimmer for examples.
Conditional expressions and flow control - These allow you to execute a command if and when a particular condition occurs. Or you can execute commands for each element in a list (see clean-rptdir).
Redirection of input/output - Among other uses, this can be used to create and email a session file.
Variables - A variable name can consist of alphanumerics and the underscore. The value of a variable is a string which can be retrieved by prefixing the name of the variable with the dollar sign ($).
Built-in shell variables - Are automatically set by the shell. Examples are :
$0 - the command, or script name
$? - the exit value of last executed command
$$ - process number of current process
$1 - first argument on command line - these positional parameters range from 1 to 9
|
patron-update2
patron-update3
patron-update4
patron-update5
|
bk-vygr-dl02
bk-vygr-dl03
|
| Advanced functionality
|
Example #1 patron-update
|
Example #2 bk-vygr-dl0
|
Functions - Like variables, functions can save you from repeating the same section of code over and over. They also allow you to organize a script into logical subsections. See load-tape and patron-extract for examples.
Sourcing a file - Regularly used variables, commands, and functions can be saved in a file and read into a script. An example is when /export/home/voyager/.profile sources the /usr/local/bin/oraenv file.
|
Command |
Shell/Program |
|
. file |
Bourne shell |
|
. file |
Korn shell |
|
source file |
C shell |
|
require file |
Perl |
Sed and awk - Sed (a stream editor) and awk (a pattern-matching programming language) are Unix utilities that can be used within scripts. See patron-extract for examples.
|
patron-update6
|
bk-vygr-dl04
|