![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Using Apex Shell The Apex Shell scripting language is implemented by the interpreter apex_shell. This discussion of Apex Shell (the scripting language) and apex_shell (its interpreter) parallels that of cshell (the language) and csh (its interpreter).
Command-Line OptionsThe interpreter apex_shell takes some of the standard csh options and supplements these with some of its own. To display the available options, type apex_shell with no arguments.
mario% apex_shellUsage
apex_shell [options
] filename [arguments
]Options
Interactive Operationapex_shell -i runs the interpreter interactively. This can be very useful to develop small scripts or portions of scripts, or to explore the behavior of unfamiliar objects.
Use exit to terminate the shell:
> apex_shell -i apexsh: view v /users/john/hello.ss/2.0.0/project_red.wrk apexsh: echo `v.languages` Ada apexsh: echo `v.subsystem_relative_name` 2.0.0/project_red.wrk apexsh: exit
Running Apex Shell ScriptsAs with csh, provide the filename of the script as an argument following any apex_shell options. Any arguments following the script's filename are passed to it as arguments.
> cat foo.apexsh echo "There were $#argv arguments" for ( set i=1; "$i" <= "$#argv"; @ i++) echo `$'$i = $argv[$i] end > apex_shell -e foo.apexsh hello there There were 2 arguments $1 = hello $2 = there
Batch Scripts
Often you want to be able to execute a script written in Apex Shell without explicitly invoking apex_shell. The usual UNIX convention is to set the file's execute permissions and start the first line with #! followed by the interpreter's pathname.
However, the pathname must be fully-qualified and cannot contain environment variables, while the apex_shell executable (which is actually an entry point into apex itself) is not loaded into a fixed location.
One method is to simply put the full pathname to apex_shell in the file:
#! /aloha/products/releases/apex.3.2.0/sun4_solaris2/bin/apex_shellThis works only for a single-architecture site, since it points directly to the executable for Solaris. A site that also had Apex for, say, HP-UX would want the script to use the executable that matches the current machine.
A more flexible strategy is to create a link such as /bin/apex_shell on each machine, linking this name to the architecturally correct apex_shell. Then the top of the script would simply be #! /bin/apex_shell.
While this provides portability, it does require maintenance on each development machine. Also, /bin/apex_shell will need to be updated if a newer version of Apex is installed in the future. Finally, large installations may end up running several versions of Apex concurrently, obviating this approach.
A third strategy is to use a wrapper to call the interpreter apex_shell. In this example, to call the script do_it.apexsh, we create the following Bourne shell wrapper do_it in the same directory and set its execute permission.
#! /bin/sh # Call apex_shell for this command's .apexsh script. Enable preprocessing. cmd=$0 apex_shell -P $cmd.apexsh "$@"
While this approach avoids the drawbacks of the other two, it comes at the expense of an extra file for each script.
Rational Software Corporation http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2001, Rational Software Corporation. All rights reserved. |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |