PDA

View Full Version : Domain lookup?


Lim Chee Beng
08-03-2004, 03:23 PM
I have an identical set of macro loaded in 2 sites, one in US and another in Asia. Hence, I'm looking for a programatic method in Windows ME10 macro, to determine where the PC is located. This will help ME10 to decide which server the macro should be loaded from.
1. What is the best (environment) variables to check in order to determine the PC location?
2. How to retrieve the info and pass to ME10 macro?

Appreciate for advice.

clausb
08-03-2004, 08:24 PM
Windows keeps the name of the current domain in the environment variable USERDOMAIN. Maybe you can simply check that variable and base your decisions upon it.

Claus

Lim Chee Beng
08-03-2004, 09:28 PM
Yes, it manages to pull the "USERDOMAIN" out from system. However, we use one identical userdomain across the whole world. :-(

clausb
08-03-2004, 09:50 PM
Aha, so you don't want to inquire the Windows domain, but the IP domain name of the system.

There must be a simpler way, but one way to do it is to call nslookup and grep for pattern in the output. Example:


nslookup %COMPUTERNAME% | findstr Name


Such a command sequence could be executed from within OSDM or OSDD using the available "system" or "run" command variants.

Claus

Lim Chee Beng
08-04-2004, 10:46 PM
I'm not sure how nslookup works in general. However, it doesn't work if I key in my PC as below.

nslookup %COMPUTERNAME% | findstr NAME > FILE.EXT

%COMPUTERNAME% is just a computer name without domain, and it's not acceptable for nslookup command.
Even the command works, I have to get output thru a text file indirectly.
I most probably opt to run a batch file (created by our administrator) to set a new IP_DOMAIN variable during the Drafting startup. Then GETENV can get the IP value from Drafting process environment variable.

Anyway, thanks for suggestion.

clausb
08-04-2004, 11:27 PM
%COMPUTERNAME% contains just the name of the computer, not the domain name on my system, and yet nslookup works just fine for me. I _think_ this has to do with the DNS setup on your system (default domain).

findstr generates a return code. If the pattern matches, you get a different return code than if it doesn't match. You can use that to detect your domain without having to write the findstr result into a file.

Example:


nslookup %COMPUTERNAME% | findstr Name | findstr cocreate.com


The above code checks if the system is in the cocreate.com domain. If it is, then the return value of the above pipe should be 0, otherwise 1. I believe that Drafting's system command (or whatever the equivalent in Drafting is) returns that value to you so that you can check for it.

Claus

Lim Chee Beng
08-05-2004, 07:00 PM
I'm not sure I understand your idea correctly. :o
Do you mean that we can issue the following command in Drafting to get the NSLOOKUP return value?

DISPLAY (RUN 'nslookup %COMPUTERNAME% | findstr Name | findstr cocreate.com')

I actually get the following message from Drafting.
*** ')' expected

clausb
08-05-2004, 09:49 PM
I am not a Drafting expert, so I cannot comment on the syntax of the RUN or DISPLAY commands. However, I just tried the basic approach in OSDM, and there it works:


(display (oli:sd-sys-exec "nslookup %COMPUTERNAME% | findstr Name | findstr cocreate.com"))


This displays 0 if the system is in the cocreate.com domain, else 1. Something similar should be possible in Drafting as well.

The 0 or 1 is the result of the complete command pipe, not just of nslookup. So you get a 0 (for "success") only if nslookup works and the two findstr commands find their specified patterns in the output of nslookup.

However, as you said that nslookup doesn't work on your systems, or at least not when passing it %COMPUTERNAME% as an input, the above is probably not an option for you anyway 8-(

Alternative ideas: Maybe Drafting has builtin system inquiry commands which can give you a hint. Also, inquiring the domain name is not the only option. In your case, the current time zone could probably also be used as an indicator of location, and maybe there is a handy way to inquire the time zone.

Claus

Wolfgang
08-06-2004, 12:44 AM
Hi Lim,

I can confirm the problem you reported with *** ')' expected

as soon as RUN is surrounded with the brackets you will get that ME10 error message. :(

I could reproduce this with 2DD 10.00 as well as with 12.X.

Work around might be to redirect nslookup output to a temp file (using RUN without the brackets) and read in the temp file with ME10 filing commands. -- not so nice.. but if it's only done once during start up of ME10 it might be acceptable.