A Registry Read Function in DataStageTX 8.0 ?

Formally known as "Mercator Inside Integrator 6.7", DataStage TX enables high-volume, complex transactions without the need for additional coding.

Moderators: chulett, rschirm

Post Reply
Keith
Participant
Posts: 18
Joined: Fri Sep 21, 2007 6:44 am
Contact:

A Registry Read Function in DataStageTX 8.0 ?

Post by Keith »

The Need :!:

To read the following from each server :
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName
WHY?
:?:

So as to capture the COMPUTER NAME in a map. :idea:
Example:
Say you had maps running on several servers and you wanted a notification sent to you concerning a reject or a report; ...in that type of reporting you wanted to know which Computer /Server/Name it was coming from.

:twisted:
What I dont want to do
:x I dont want to have a file.txt on each server with the respective computer name. I know I could do that , but should the respective computer name be changed it means I have to change the file.txt .
Keith
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Yeah, you can read the value and store in to that file before executing you Datastage jobs. And optionally remove the input file after the extract.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
janhess
Participant
Posts: 201
Joined: Thu Sep 18, 2003 2:18 am
Location: UK

Post by janhess »

kumar_s wrote:Yeah, you can read the value and store in to that file before executing you Datastage jobs. And optionally remove the input file after the extract. ...
How? Can this be run as a batch job from within the DSTX/WTX map?
Keith
Participant
Posts: 18
Joined: Fri Sep 21, 2007 6:44 am
Contact:

IBM says 'NADA' 'negative' 'no'

Post by Keith »

:( IBM says there is no function available. :x They recommend that I use the EXIT() map ,function. This functions allows your map to interface with an external application and return the results back to your map.

:idea: I believe I am going to try making a .bat file and insert the DOS command 'IPCONFIG'. Feed the results to a .txt file and have a map read the .txt file until I get to the IP address and then when I read the IP address; do a lookup on a table to find the corresponding computer name assigned to that IP address.
wait ,....on the other hand the IPCONFIG/all will give me the name of the computer "Host Name...........computer name".

I should be able to perform the above comfortable in a map. what do you think? :?:
Keith
janhess
Participant
Posts: 201
Joined: Thu Sep 18, 2003 2:18 am
Location: UK

Post by janhess »

You can have an input card which runs the batch file containing the ipconfig/all
This returns the output of the bat file to the input card. You can then extract the host name.
cppwiz
Participant
Posts: 135
Joined: Tue Sep 04, 2007 11:27 am

Post by cppwiz »

You could export the registry key from the command line, then read the file.

http://support.microsoft.com/kb/168589/en-us
rep
Participant
Posts: 82
Joined: Tue Jun 19, 2007 8:04 am
Location: New York City

.....

Post by rep »

Use the resource registry?
janhess
Participant
Posts: 201
Joined: Thu Sep 18, 2003 2:18 am
Location: UK

Re: .....

Post by janhess »

rep wrote:Use the resource registry?
Might as well just use a file. It's still got to be changed for each machine.
I think a generic solution was required. However, I'm not sure how to do this for different operating systems.
Keith
Participant
Posts: 18
Joined: Fri Sep 21, 2007 6:44 am
Contact:

What I ended up doing

Post by Keith »

Created a bat file first : Called Config_dos.bat ..here is the content !

cd %1
ipconfig/all > %2

Then created the map to call the .bat :

=IF(cmd_line5 Fields:trigger_out="config.txt", RUN("Run_config.mmc","-OABAT1 '-cmd " + "''Config_dos.bat " + cmd_line3 Fields:trigger_out + " "
+ cmd_line4 Fields:trigger_out + ".txt" + "''" +" -T'"),"No IPCONFIG activated")
-----------------------------------------------------------------------------
Cmd_line3 = "c:\"
cmd_line4 = "d:\Mercmvs\Test_Computer_Name\config"
cmd_line5 = "config.txt"
---------------------------------------------------------------------------

The Run_config.mmc has an output card with a Group Sub class [Item] and a field :

The Group Subclass = Sequence and the component is delimited with a Literal = <CR> <LF>
the Field item is Text and the size is Min=0 Interpret as character.
---------------------------------------------------------------------------------
The result is :

Windows IP Configuration

Host Name . . . . . . . . . . . . : JAX9999999-1
Primary Dns Suffix . . . . . . . : TEST.COM
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : test.com
mpd.jax.test.com
jax.test.com

Ethernet adapter Local Area Connection 4:

Connection-specific DNS Suffix . : test.com
Description . . . . . . . . . . . : Intel(R) 82566DM Gigabit Network Connection
Physical Address. . . . . . . . . : 99-0F-FE-53-C6-E0
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 99.99.114.248
Subnet Mask . . . . . . . . . . . : 255.255.254.0
Default Gateway . . . . . . . . . : 99.99.114.1
DHCP Server . . . . . . . . . . . : 99.99.131.12
DNS Servers . . . . . . . . . . . : 99.99.130.71
99.99.130.70
Primary WINS Server . . . . . . . : 99.99.131.12
Secondary WINS Server . . . . . . : 99.99.131.11
Lease Obtained. . . . . . . . . . : Friday, May 23, 2998 3:99:14 PM
Lease Expires . . . . . . . . . . : Saturday, May 31, 2998 3:99:14 PM

------------------------------------------------------------------------------------
At that point I have another map that reads the above data and capture what I need. In this case all I need is the 'Host Name' .

=IF( MID( Host_name Field:Config_data<>IpConfig_Record:Map_log,9,4)="Host", Config_data<>IpConfig_Record:Map_log,none )
---------------------------------------------------------------------------------
Keith
jgibby
Participant
Posts: 42
Joined: Thu Dec 16, 2004 8:48 am

Post by jgibby »

If you have the computername in an environment variable, you can use this:

Code: Select all

WORD(GET("BAT","-cli -cmd '@ECHO ""!COMPUTERNAME!"" '"),"""",2)
But if not you can use IPCONFIG by doing this:

Code: Select all

=WORD(
	WORD(
		WORD(
			GET("BAT","-cli -cmd '@IPCONFIG /ALL'")
			,"Host Name"
			,2
		)
		,"<CR>" // Don't use <NL> here
		,1
	)
	,": "
	,-1
)
I used a <CR> instead of <NL> because, for some weird reason, the output from IPCONFIG terminates its lines with <CR><CR><LF>. So using <CR> was the most efficient fix.
"Artificial intelligience is no match for natural stupidity."
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

warning!!!! I have no TX experience but...


The command "Hostname" is supported in both Unix and WinXP (Therefore should be supported in WinServ2003).

That should give you only and exactly what you need.. if i understand the requirement right.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
jgibby
Participant
Posts: 42
Joined: Thu Dec 16, 2004 8:48 am

Post by jgibby »

Excellent tip ameyvaidya!

This works like a charm.

Code: Select all

=SUBSTITUTE(
	SUBSTITUTE(
		GET("BAT","-cli -cmd '@HOSTNAME'")
		,"<CR>"
		,""
	)
	,"<LF>"
	,""
)
"Artificial intelligience is no match for natural stupidity."
janhess
Participant
Posts: 201
Joined: Thu Sep 18, 2003 2:18 am
Location: UK

Post by janhess »

Or even simpler
=SUBSTITUTE( GET("BAT","-cli -cmd '@HOSTNAME'") ,"<NL>" ,"" )
jgibby
Participant
Posts: 42
Joined: Thu Dec 16, 2004 8:48 am

Post by jgibby »

janhess wrote:Or even simpler
=SUBSTITUTE( GET("BAT","-cli -cmd '@HOSTNAME'") ,"<NL>" ,"" )
You're right (as always). I was concerned that it might produce the same weirdness that ipconfig does with the double <CR><CR><LF>. But I looked at it's output in binary and it does not have that issue so your method is more simple and efficient!

jgibby < bows to janhess' superiority
:wink:
"Artificial intelligience is no match for natural stupidity."
jvmerc
Participant
Posts: 94
Joined: Tue Dec 02, 2003 12:57 pm

Post by jvmerc »

I defined my input as text and the card as batch with a commandline of

-cmd hostname

My text field is defined with a <NL> terminator so I don't need substitute.

Only problem with this method is it runs at run-map level so I'd need to pass it to f_maps if I wanted the value deeper in the map.
Post Reply