Login | |
|
 |
VBS - NSLOOKUP - 10/20/2008 12:10:07 AM
|
|
 |
|
| |
Enparo
Posts: 2
Score: 0
Joined: 10/20/2008
Status: offline
|
This is my first script, and i've run into a problem I'm not able to solve so far. - Whot does the script do so far It executes CLI and runs Nslookup command with some additional parameters. It writes the info to a textfile. Then it will search for a specific 'trigger' (nameserver) and saves everything to the right into the textfile. So everything before the first nameserver is deleted and the 1st nameserver ends up in the first line of the .txt. - The problem: I want the script to output only the nameservers, as this is different for every domain I can't search for a specific word. Also different domains have different numbers of nameservers. - Solution? As the first line of the .txt is the 1st nameserver, could I save this to another textfile. Then loop it until all nameservers are found. It saves everthing to the right of Nameserver: (so it wont save Nameserver) which is good when I loop it will go to the second one. Next I can stop the loop when (nameserver) isnt found anymore That was my thought on it. No idea how to accomplish it tho Need some help here =) Script ---------------------------------------- Dim objShell Const ForWriting = 2 Const Createifnotexist = true Domeinnaam=Inputbox ("Enter a domainname:") strFilePath = "C:\Documents and Settings\Administrator.TESTSERVER\Bureaublad\vbs.t xt" Set objFSO = Createobject("Scripting.FileSystemObject") Set objShell = CreateObject("WScript.Shell") Set objExec = objshell.Exec ("%comspec% /c nslookup -querytype=ns " & Domeinnaam) strLookup = objExec.stdout.readall trigger = "nameserver =" if instr (1,strlookup,trigger,1) >0 then position = instr (1,strLookup,trigger) Strlookup = Right (strLookup,(len(strlookup) -position -len(trigger))) WScript.echo position Else Wscript.echo "Failure!" End If Set objFile = objFSO.Opentextfile(strFilepath, ForWriting, Createifnotexist) Objfile.Writeline strLookup objFile.Close WScript.Quit ---------------------------------------------- I'm not english so please... keep it to a level i'll understand. Help appreciated ..!
|
|
| |
|
|
|
 |
RE: VBS - NSLOOKUP - 10/20/2008 7:06:06 PM
|
|
 |
|
| |
Enparo
Posts: 2
Score: 0
Joined: 10/20/2008
Status: offline
|
Input: google.com Output: ns1.google.com google.com nameserver = ns2.google.com google.com nameserver = ns3.google.com google.com nameserver = ns4.google.com ns1.google.com internet address = 216.239.32.10 ns2.google.com internet address = 216.239.34.10 ns3.google.com internet address = 216.239.36.10 ns4.google.com internet address = 216.239.38.10 --------------------------------------------------------------- I've going in this direction at the moment: (not working tho, maybe just a lil) -------------- Dim objShell Const ForWriting = 2 Const ForReading = 1 Const Createifnotexist = true Domeinnaam=Inputbox ("Enter a domainname:") strFilePath = "C:\Documents and Settings\Administrator.TESTSERVER\Bureaublad\vbs.txt" Set objFSO = Createobject("Scripting.FileSystemObject") Set objShell = CreateObject("WScript.Shell") Set objExec = objshell.Exec ("%comspec% /c nslookup -querytype=ns " & Domeinnaam) strLookup = objExec.stdout.readall trigger = "nameserver =" if instr (1,strlookup,trigger,1) >0 then position = instr (1,strLookup,trigger) Strlookup = Right (strLookup,(len(strlookup) -position -len(trigger))) WScript.echo position Else Wscript.echo "Failure!" End If Set objFile = objFSO.Opentextfile(strFilepath, 2, Createifnotexist) Objfile.Writeline "*" & strLookup objFile.Close searchprefix = "*" Do Until objFile.AtEndofStream strline = objFile.Readline Searchresult = instr(strline, searchprefix) If Searchresult > 0 then Wscript.echo strline end if Loop WScript.Quit --------------- I know this won't work, but here some interesting new output: Now I have a definded character, Is it possible to write the first line to another .txt and then repeat with the others. Next problem I'm running into is that the vbs.txt first must be ForWriting and after ForReading, I've read i can only use one. Ideas? *ns1.google.com google.com nameserver = ns2.google.com google.com nameserver = ns3.google.com google.com nameserver = ns4.google.com ns1.google.com internet address = 216.239.32.10 ns2.google.com internet address = 216.239.34.10 ns3.google.com internet address = 216.239.36.10 ns4.google.com internet address = 216.239.38.10 Thnx in advance
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|