Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Running a shell script z/OS UNIX System Services User's Guide SA23-2279-00 |
|
You can run a shell script by typing the name of the file that
contains the script. For example, suppose you have a script named totals.scp that
has three shell commands in it. If you enter:
the
shell runs the three commands.Before you can run a shell script, you must have read and execute permission to the file. Use the chmod and umask commands to set the permissions. See the discussion of permissions in Handling security for your files. See the descriptions of chmod and umask in z/OS UNIX System Services Command Reference. For another example, suppose you want to compile a collection of
files written in the C programming language. You could use the c89, cc,
or c++ command. The c89 command,
for example, compiles any file file.c, link-edits the object
module, and produces an executable file. The shell script:
compiles
and link-edits the files and produces an executable file, outfile.
Notice that in a shell script you precede a comment with a #.If you store this script in an executable file named compile, it could be run with the single command compile. A new process is created for the script to run in. To run a shell script in your current environment, without creating
a new process, use the source command.
You could run the calculate shell
script this way:
Should you
want to use a shell script that updates a variable in the current
environment, run it with the source command.Tip: To improve shell script performance, set the _BPX_SPAWN_SCRIPT environment
variable to NO when using the tcsh shell. This variable is intended
only for use with the z/OS® shell.
If this variable is inherited from a z/OS shell
session, put
as the first line
in your tcsh shell scripts to avoid any errors. If tcsh is your login
shell, you should unset _BPX_SPAWN_SCRIPT,
because it is only used for increasing performance of z/OS shell scripts. |
Copyright IBM Corporation 1990, 2014
|