Page 1 of 1

A Registry Read Function in DataStageTX 8.0 ?

Posted: Thu May 15, 2008 12:00 pm
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 .

Posted: Thu May 15, 2008 3:17 pm
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.

Posted: Fri May 16, 2008 2:31 am
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?

IBM says 'NADA' 'negative' 'no'

Posted: Fri May 16, 2008 7:05 am
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? :?:

Posted: Fri May 16, 2008 8:29 am
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.

Posted: Fri May 16, 2008 8:43 am
by cppwiz
You could export the registry key from the command line, then read the file.

http://support.microsoft.com/kb/168589/en-us

.....

Posted: Fri May 16, 2008 9:12 am
by rep
Use the resource registry?

Re: .....

Posted: Fri May 16, 2008 9:17 am
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.

What I ended up doing

Posted: Tue Jun 03, 2008 8:24 am
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 )
---------------------------------------------------------------------------------

Posted: Wed Jun 04, 2008 11:03 am
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.

Posted: Thu Jun 05, 2008 3:26 am
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.

Posted: Thu Jun 05, 2008 8:27 am
by jgibby
Excellent tip ameyvaidya!

This works like a charm.

Code: Select all

=SUBSTITUTE(
	SUBSTITUTE(
		GET("BAT","-cli -cmd '@HOSTNAME'")
		,"<CR>"
		,""
	)
	,"<LF>"
	,""
)

Posted: Thu Jun 05, 2008 8:58 am
by janhess
Or even simpler
=SUBSTITUTE( GET("BAT","-cli -cmd '@HOSTNAME'") ,"<NL>" ,"" )

Posted: Thu Jun 05, 2008 9:43 am
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:

Posted: Thu Jun 05, 2008 8:33 pm
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.