2.1.3.4 Running Scripts
TXST incorporates three ways for running scripts. To run the script examples in this guide, copy and save the commands in a text file with a .py file extension, for example, filename.py. Use the text file with the commands for running scripts that are listed below. There are sample scripts that you can use as a template when creating a script.py file from scratch. If the script will connect TXST to a running Tuxedo domain, start Tuxedo domain before running the script.
You can run the script in three modes:
- Invoke TXST and run a script:
java oracle.tuxedo.TXST myscript.py - run a script from TXST:
execfile(‘myscript.py’)
Listing 2‑2 Running script myscript.py
connect("//localhost:5037", "simpapp", "38075");
cd('simple/GROUP1')
ls('c')
disconnect()
exit()- Invoke the TXST script from an Ant build file
Scripts invoke a sequence of TXST commands without requiring your input, much like a shell script. Scripts contain TXST commands in a text file with a .py file extension.
TXST provides a custom ant task to invoke the TXST script from an Ant build file. If you want to use the task with your own Ant installation,add the following task definition in your build file:
<taskdef name ="txst" classname="oracle.tuxedo.jmx.tux.jyscript.TXSTTask"/> - To run TXST from an Ant script:
- Set your environment in a command shell,which include
TUXDIR,CLASSPATH,JAVA_HOME,ANT_HOMEand so on. - Add a call to the txst Ant task to execute TXST commands. For example:
<target name="GetParameters"> <txst debug="false" failOnError="false" executeScriptBeforeFile="true" fileName="./test.py"> <script> connect("//slce04cn03:5067","simpapp","38175") ls() print cmo.GetParameters() </script> </txst> </target>Using the txst Ant task, you can specify TXST commands within a TXST script(.py), using the fileName attribute, or embed TXST script commands inside the build file, within the <script> tags.
- Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging directory, optionally passing the command a target argument:
bash-3.2$ ant getParameters - the syntax of the txst Ant task is as follows:
<txst properties="propsFile" filename=”filename” arguments="arglist" failOnError=”value” executeScriptBeforeFile="value” debug=”value” ><script>txst-commands</script>
- Set your environment in a command shell,which include
Table 2-1 Ant Task Attributes
| Attribute | Definition |
|---|---|
properties="propsFile"
|
Optional. Name and location of the properties file that contains name-value pairs that you can reference in your script. |
fileName="fileName"
|
Optional. Name and location of the TXST script file that you would like to execute. If the specified TXST script file does not exist, the txst Ant task fails. |
arguments="arglist"
|
Optional. List of arguments to pass to the script. These arguments are accessible using the sys.argv variable. |
failOnError="value"
|
Optional. Boolean value specifying whether the Ant build script will fail if the txst Ant task fails. This attribute defaults to true. |
executeScriptBeforeFile="value"
|
Optional. Boolean value specifying whether the embedded script is executed before the specified TXST script file. This attribute defaults to true, specifying that the embedded script is executed first. |
debug="value"
|
Optional. Boolean value specifying whether debug statements should be output when the TXST Ant Task is executed. This attribute defaults to false. |
script node:<project default="all" basedir=".">
<taskdef name ="txst" classname="oracle.tuxedo.jmx.tux.jyscript.TXSTTask" />
<target name="getParameters">
<txst debug="false" failOnError="false" executeScriptBeforeFile="true" fileName="./test.py">
<script>
connect("//slce04cn03:5067","simpapp","38175")
cmo.GetParameters()
</script>
</txst>
</target>
</project>TXST does not support Maven in this version.
Parent topic: Main Steps for Using TXST