Computing.Net > Forums > Disk Operating System > Resolve MX-record from DNS into var

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Resolve MX-record from DNS into var

Reply to Message Icon

Name: ikerstges
Date: March 23, 2004 at 03:06:50 Pacific
OS: Windows2000-DOS
CPU/Ram: PIII/1024
Comment:

Hi,

I'm using blat (http://www.blat.net/) to send emails from batch-scripts. (w2k command environment) I always used sent my emails directly to the smpt-server name, but that will not work anymore. Instead I need to request the smtp servername from dns by reading the MX-record.

For this, I can type
1) nslookup <enter>
2) set querytype=mx <enter>
3) [domainname] <enter>

The results look similar to:
scct.emea.company.com MX preference = 20, mail exchanger = cli-location-195.scct.emea.company.com
scct.emea.company.com MX preference = 10, mail exchanger = cli-location-194.scct.emea.company.com
scct.emea.company.com nameserver = kate.company.com

I need to store into a variable the results:
a) cli-location-195.scct.emea.company.com
b) cli-location-194.scct.emea.company.com

Does someone have any suggestions how to achieve this?

Thanks in advance!
Igor.



Sponsored Link
Ads by Google

Response Number 1
Name: ikerstges
Date: March 23, 2004 at 03:19:20 Pacific
Reply:

HMmm....

Just found that commandline:

nslookup -querytype=mx [domainname] <enter>

gives the disired information, now I need to capture the two servernames from the lines with MX exchangers....


0

Response Number 2
Name: ikerstges
Date: March 23, 2004 at 05:11:01 Pacific
Reply:

I have tried to use the "=" sign from the nslookup output as delimiter in following line:
FOR /F "tokens=1,2,3 delims==" %a in ('nslookup -type=mx scct.emea.fedex.com') do set SMTPSERVER=%c

However, this results in an error message for the nslookup command due to the fact that it needs input from DNS but it is executed between '....' and this prevents input from the system to the nslookup statement.

I believe I will need to use some sort of piping and/or filtering of the output to achieve my desired results....

Any help will be highly appreciated!

Igor.



0

Response Number 3
Name: Wengier
Date: March 23, 2004 at 05:19:00 Pacific
Reply:

"FOR /F "tokens=1,2,3 delims==" %a in ('nslookup -type=mx scct.emea.fedex.com') do set SMTPSERVER=%c"

Have you noticed that this is a NT batch command instead of a DOS batch command? NT batch command works only on a NT system (WinNT/2K/XP), not on a DOS system. And you have said it is a w2k command environment, not a DOS command environment at all. Please post this question in the correct forum, as the warning messages of this forum state. Quotaton of the warning messages of this forum:

"DO NOT post questions related to NT Batch scripting on this forum. Use the Programming forum.

Use the Windows NT, 2000 or XP forum for questions regarding the Windows NT, 2000 or XP "DOS" command prompt."

For more information about the "Command Prompt" (Win32 Console) in NT systems (WinNT/2K/XP), you may read this page:

http://mywebpages.comcast.net/stewartb/cmdprompt.html

---------------
Long Live DOS!


0

Response Number 4
Name: ikerstges
Date: March 23, 2004 at 05:26:05 Pacific
Reply:

My apologies!


0

Response Number 5
Name: Wengier
Date: March 23, 2004 at 05:45:10 Pacific
Reply:

That's OK, thanks.

This thread has been redirected to Programming Forum by now:

http://computing.net/programming/wwwboard/forum/9964.html

---------------
Long Live DOS!


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Resolve MX-record from DNS into var

first word from textfile into var?? www.computing.net/answers/dos/first-word-from-textfile-into-var/16200.html

three lines from txt into a var www.computing.net/answers/dos/three-lines-from-txt-into-a-var/14624.html

get TIME & DATE into var www.computing.net/answers/dos/get-time-amp-date-into-var/15536.html