Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.comI need to store into a variable the results:
a) cli-location-195.scct.emea.company.com
b) cli-location-194.scct.emea.company.comDoes someone have any suggestions how to achieve this?
Thanks in advance!
Igor.

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....

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=%cHowever, 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.

"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!

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!

![]() |
![]() |
![]() |

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