Pick up data from system variables ?

Support for DataSlave

Moderators: Tom, ian

Pick up data from system variables ?

Postby ceejayemm » Fri Feb 11, 2011 1:49 pm

Is it possible to include data from System Variables in a map ? On our servers we have %computername% defined to show (in DOS Batch files) the name of the server the process is being run on. Is there any way I could also pick up variables of this type for use in a map ?

Thanks

Chris
ceejayemm
 
Posts: 22
Joined: Mon Apr 23, 2007 1:29 pm
Location: London, UK

Re: Pick up data from system variables ?

Postby ian » Fri Feb 11, 2011 2:27 pm

There is a Transform Function, Literal. This allows for example the date, time map name and machine name to be added to the data.

If this does not have the data you need you will need to use a Script object. What data do you need to add?
ian
 
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Re: Pick up data from system variables ?

Postby ceejayemm » Fri Feb 11, 2011 4:08 pm

I know about the literals functionality. What I am trying to do is to ensure that when we move a map from our development enviroment to the runtime production system I can pick up the name of the serverthe map is running on as some of my transforms require this information. I don't want to hard code them in literals unless I can avoid it.

If you run a DOS command window and type 'set' (without the quotes) followed by a return you will see all the system variables set on your computer. One of these on our servers is the server name, in the same DOS command window if I typed 'set computername' I would get 'ICR2WTESTPI' returned on our dev system whilst the same command on our Prod system would return 'ICR2WPUB' for example. Depending on the computername returned I can then write other variables into output files to be executed later on that server.

Chris
ceejayemm
 
Posts: 22
Joined: Mon Apr 23, 2007 1:29 pm
Location: London, UK

Re: Pick up data from system variables ?

Postby ian » Fri Feb 11, 2011 8:02 pm

Okay thanks for the explanation. You should download version 2.2.4, which will go into general release soon.

This has a new feature that allows a DBC file to be placed in the same folder as the map containing substitutions for map parameters. The idea is that when you move a map into production from a test server you have a dbc file in each location with the credentials and connections strings for the test or production server.

I am not sure if I am explaining well, but have a look at the release note and help file for 2.2.4. If you need more explantion please let us know.

The links are:

http://www.baycastle.co.uk/products/dat ... _Setup.exe
http://www.baycastle.co.uk/products/dat ... _Setup.exe
ian
 
Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Re: Pick up data from system variables ?

Postby ceejayemm » Mon Feb 14, 2011 9:49 am

I solved mu problem by adding a VBScript function into one of my Transform sections. The code is:

' Transform Script Function
' Used to create new output values from input values.
' Inputs and Outputs are ScriptVariable objects, use
' syntax: Output1.Value = Input1.Value etc.
' Return True if function executes correctly, otherwise False.

Function Transform(Input1, Output1, Output2)

' TODO: add transformation code here

'Declare Variables
Dim WshShl, UserVar

'Set objects
Set WshShl = CreateObject("WScript.Shell")

'Read variable
UserVar = wshShl.ExpandEnvironmentStrings( "%computername%" )

'Output value
Output1.Value = UserVar

'Cleanup Objects
Set WshShl = Nothing

Transform = True

End Function

It seems to work for what I want.

I will pull down the latest version of DS and see if the new fucntionality does this any better.

Thanks

Chris
ceejayemm
 
Posts: 22
Joined: Mon Apr 23, 2007 1:29 pm
Location: London, UK


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron