Loading Variable and values from file and saving file

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.

Loading Variable and values from file and saving file

Postby Frank_CMRG » Wed Dec 08, 2010 4:48 pm

How do I load a file with Variable Definitions into my project?

We have 3 systems, TEST, DEVelopment, and PRODuction. When testing new projects, they are connecting to Test / dev servers, after migrating the project to the production Machine, we would have to edit all the connections. To avoid this, I want to create a file of Variables that have the production or test connections to use based on the Go Anywhere instance being run on.

I tried the import XML file task at the start of the project, but it returned a malformed file error.
I believe it was missing a header line, so what should the header line look like?

For example:

Here is the connection variable for our TEST hp300 FTP Server:

<variable name="HP_HOST" value="test-hp3000.cmal.com" valueIsEncrypted="false" />

the same for our Production hp3000:

<variable name="HP_HOST" value="hp3000.cmal.com" valueIsEncrypted="false" />
Frank_CMRG
 
Posts: 8
Joined: Wed Dec 08, 2010 1:49 pm

Re: Loading Variable and values from file and saving file

Postby Frank_CMRG » Tue Dec 14, 2010 11:03 am

to clarify:
I want to load a two column file.
Column 1 is the variable Name
Column 2 is the data value for the variable named.

I can make the file any format to fit:
CSV, Excel, Flat File Fixed.

I am not getting anywhere with the following project code when loading Excel:

<project name="Load Excell" mainModule="Main" version="1.0" logLevel="verbose">

<module name="Main">

<readExcel version="2.0" inputFile="D:\GoAnywhere\userdata\documents\fgirard\HP_VARS\GO_ANYWHERE_VARIABLE_TABLE.xls" outputRowSetVariable="Xcel_vars" dataStartRowNumber="5" headingsRowNumber="1" sheetNames="TEST" numColumns="3" skipEmptyRows="true">
<data trim="both">
<column index="1" name="Var_name" type="VARCHAR" size="40" trim="both" />
<column index="3" name="Var_value" type="VARCHAR" size="40" trim="both" />
</data>
</readExcel>

<forEachLoop itemsVariable="${Xcel_vars}" currentItemVariable="row">

<setVariable version="2.0" name="variable_name" value="${Xcel_vars:Var_name}" />


<print version="1.0">
<![CDATA[.
Row Variables: ${row}
.
variable_name : ${variable_name}]]>
</print>

</forEachLoop>
</module>

</project>
Frank_CMRG
 
Posts: 8
Joined: Wed Dec 08, 2010 1:49 pm

Re: Loading Variable and values from file and saving file

Postby Support_Duane » Tue Dec 14, 2010 6:45 pm

There are two problems here.
1. When retrieving a value from a rowset, you must reference the current row, and then in brackets reference either a column number or column name. So in the example you provided, since the "currentItemVariable" in the loop is "row", instead of:
Code: Select all
  <setVariable version="2.0" name="variable_name" value="${Xcel_vars:Var_name}" />

you should use:
Code: Select all
<setVariable version="2.0" name="variable_name" value="${row[Var_name]}" />

or:
Code: Select all
<setVariable version="2.0" name="variable_name" value="${row[1]}" />


2. You cannot specify a variable as the left element of a set variable task. Check out the following:
invalid:
Code: Select all
<setVariable version="2.0" name="${var1Name}" value="${var1Value}" />

valid :
Code: Select all
<setVariable version="2.0" name="var1Name" value="${var1Value}" />


The valid line above will assign the value of the "var1Value" variable to the "var1Name" variable.
Support_Duane
Support Specialist
 
Posts: 65
Joined: Thu Mar 05, 2009 3:49 pm

Re: Loading Variable and values from file and saving file

Postby Frank_CMRG » Mon Dec 20, 2010 2:48 pm

Duane,
Our E-mail is down at the moment, so did not know you posted another way to do this.
I was checking back to say that I figured out how to load the Variable declarations and values. You sent something to Jim about 'snippets' searching on that got me the information I needed to load all the variables from a file:

<module name="variables">
<variable name="HP_HOST" value="test-hp3000.cmal.com" valueIsEncrypted="false" />
<variable name="HP_USER" value="jobs.bttest" valueIsEncrypted="false" />
<variable name="HP_PW" value="y3sY4Wys16A=" valueIsEncrypted="true" />
</module>

I was not putting the variables in a <module> tag grouping, once I did this, they loaded fine. So I now have 2 ways to load the variables - I was able to get the 'call project' version working, and now this one.

I am going to look at the new example and get that working, and then I can present the 3 version to the group, and then finalize the standard we are going to use going forward between us.

thanks for you help on this.

Frank
Frank_CMRG
 
Posts: 8
Joined: Wed Dec 08, 2010 1:49 pm


Return to Community Forum

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

cron