Retrieve System Name
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
4 posts
Page 1 of 1
- Support Specialist
- Posts: 10
- Joined: Tue Mar 03, 2009 5:45 pm
At this time there is no variables available in GoAnywhere to retrieve this information.
You could however add a program call to retrieve this information for now
Thanks
Ron
You could however add a program call to retrieve this information for now
Thanks
Ron
-
Support_Sai
It is possible in GoAnywhere to define and import a set of variables that could act as global/system variables. You can import parts of a project from external XML files. This works much like the COPYBOOK feature in System i programs.
Follow the instructions below to set this up:
Create a simple XML file with all global variables that you would like to import into all/most of your projects. Place the file in a folder of your choice (preferably in the ~goanywhere/userdata/imports). For this example, let us name the file as Global Variables.xml. Below are the contents of our Global Variables.xml file:
Now, we can import this file into any project and the two variables we have defined in the file will be available to the project at execution time. Below is a sample project that imports the above file and conditionally runs a task based on the system name:
Now, make a copy of the Global Variables.xml file and move it to your second system. Adjust the variable values as needed.
Not only you can import variables, but you can import other project components such as Modules and Tasks. So, it is possible to have a common E-Mail task that sends out error notifications in a separate file and import that task into several projects.
Note:
When working in the Project Designer, variables from the imported file are not displayed in the Variable Selection Drop-down. The imported file is loaded only at project's execution time. Any subsequent changes made to the imported file will be automatically reflected when the projects are executed the next time.
Follow the instructions below to set this up:
Create a simple XML file with all global variables that you would like to import into all/most of your projects. Place the file in a folder of your choice (preferably in the ~goanywhere/userdata/imports). For this example, let us name the file as Global Variables.xml. Below are the contents of our Global Variables.xml file:
Code: Select all
Basically we have two variables in this file. One that indicates the system name, and the other contains the list of email addresses to receive error notifications. <?xml version="1.0" encoding="UTF-8"?>
<globalVariables>
<variable name="global.system.name" value="S10BD458" />
<variable name="global.emails" value="[email protected], [email protected]" />
</globalVariables>
Now, we can import this file into any project and the two variables we have defined in the file will be available to the project at execution time. Below is a sample project that imports the above file and conditionally runs a task based on the system name:
Code: Select all
As you might have noticed, we imported the Global Variables.xml file into the project. To do this, right click on the Project node in the Project Designer and select Import an XML File from the context menu. During the execution of the project, the Project Compiler copies the contents of the Global Variables.xml into the project (excluding the root element, in our case <globalVariables>). The expanded project is then executed. <project name="Import Variables Demo" mainModule="Main" version="1.0">
<module name="Main">
<print if="global.system.name eq 'S10BD458'">
<![CDATA[Hello World!]]>
</print>
</module>
<import file="/linoma/goanywhere/userdata/imports/Global Variables.xml" />
</project>
Now, make a copy of the Global Variables.xml file and move it to your second system. Adjust the variable values as needed.
Not only you can import variables, but you can import other project components such as Modules and Tasks. So, it is possible to have a common E-Mail task that sends out error notifications in a separate file and import that task into several projects.
Note:
When working in the Project Designer, variables from the imported file are not displayed in the Variable Selection Drop-down. The imported file is loaded only at project's execution time. Any subsequent changes made to the imported file will be automatically reflected when the projects are executed the next time.
- Support Specialist
- Posts: 11
- Joined: Fri May 08, 2009 8:59 am
You can now perform conditional logic on the system.instanceName variable in GoAnywhere version 2.3.0. The instance name can be set in the Global Settings and is useful when you have multiple instances of GoAnywhere running. You can now use that variable in your Execute Only If logic on each task/module to control processing.
In the example below I have a Project that sends emails. I set the Execute Only If attribute to compare it to the system.instanceName. In the example the email is only sent if it's running on the Production instance of GoAnywhere.
In the example below I have a Project that sends emails. I set the Execute Only If attribute to compare it to the system.instanceName. In the example the email is only sent if it's running on the Production instance of GoAnywhere.
Code: Select all
<project name="Production Email" mainModule="Main" version="1.0">
<description>Send a notification email</description>
<module name="Main">
<sendEmail if="system.instanceName eq 'Production'" resourceId="SMTP" toList="[email protected]">
<from address="[email protected]" />
<subject>
<![CDATA[This job has completed successfully. ]]>
</subject>
<message>
<![CDATA[Jog number = ${system.job.id}]]>
</message>
</sendEmail>
</module>
</project>
4 posts
Page 1 of 1