Shyke Posted November 28, 2006 Share Posted November 28, 2006 (edited) ;=============================================================================== ; ; Function Name: _GetSMTP() ; Description: Gets ISP issued SMTP server. ; Parameter(s): None ; Requirement(s): Internet access. ; Return Value(s): On Success - Returns SMTP Server ; On Failure - Unknown ; Author(s): Shyke ; Note: Only works with normal lan or directly connected PCs, ; doesn't return the proper SMTP server in some cases. ; ;=============================================================================== Func _GetSMTP() Local $s_SMTP Run(@ComSpec & " /c nslookup > " & @TempDir & "~tt.tmp", "", @SW_HIDE) Sleep(2000) $s_SMTP = FileReadLine(@TempDir & "~tt.tmp", 1) $s_SMTP = StringTrimLeft($s_SMTP, 17) $s_SMTP = StringSplit($s_SMTP, ".") ProcessClose("cmd.exe") ProcessClose("nslookup.exe") FileDelete(@TempDir & "~tt.tmp") Return "smtp." & $s_SMTP[$s_SMTP[0] - 1] & "." & $s_SMTP[$s_SMTP[0]] EndFunc What do you guys think? If anyone sees any improvements, I'm greatly requesting that you add them. Edited May 3, 2012 by Shyke Link to comment Share on other sites More sharing options...
boomingranny Posted July 4, 2007 Share Posted July 4, 2007 i don't understand how this script would get the smtp server? its a cool idea tho reading thru it it calls nslookup then writes the result to a file... this would return the default DNS server for the computer would it not? Link to comment Share on other sites More sharing options...
jvanegmond Posted July 5, 2007 Share Posted July 5, 2007 i don't understand how this script would get the smtp server? its a cool idea thoreading thru it it calls nslookup then writes the result to a file... this would return the default DNS server for the computer would it not?Exactly! This just gets the DNS server, and not the SMTP server.It may be that in some cases it is all the same, but I doubt it. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 5, 2007 Moderators Share Posted July 5, 2007 Could shorten the function a bit as well Func _GetDNS() Local $aSRE = StringRegExp(StdoutRead(Run(@ComSpec & " /c nslookup", "", @SW_HIDE, 2)), '(?s)(?i)Default Server: .*?\.(.*?)(?m:$|\r)', 1) If IsArray($aSRE) Then Return $aSRE[0] Return SetError(1, 0, '') EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 5, 2007 Share Posted July 5, 2007 Hi, this way it will work for every language: MsgBox(0,"",_GetDNS()) Func _GetDNS() Local $aSRE = StringRegExp(StdoutRead(Run(@ComSpec & " /c nslookup", "", @SW_HIDE, 2)), '(?s)(?i)server: .*?\.(.*?)(?m:$|\r)', 1) If IsArray($aSRE) Then Return $aSRE[0] Return SetError(1, 0, '') EndFunc So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jvanegmond Posted July 6, 2007 Share Posted July 6, 2007 (edited) Hi, this way it will work for every language: So long, MegaUnless the language does not know the word Server... MsgBox(0,"",_GetDNS()) Func _GetDNS() Local $aSRE = StringRegExp(StdoutRead(Run(@ComSpec & " /c nslookup", "", @SW_HIDE, 2)), '.*?\.(.*?)(?m:$|\r)', 1) If IsArray($aSRE) Then Return $aSRE[0] Return SetError(1, 0, '') EndFunc Edited July 6, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now