Jump to content
famko

Save output from @comspeq nslookup into $var

Recommended Posts

famko

Hi everyone,

 i am strungling with a small script. I want to use nslookup to retrieve the ipadress of a website and store the ipadres into $xxxx

It is working with the script below. But i can't get i working without saving nslookup into nslookup.txt. 

Would nice if i can just save the @comspec command into $nslookup and then use the stringbetween.

Would be nice if someone could help me with this

 

 

#include<array.au3>
#include <String.au3>

$url = "www.spamhause.com"

RunWait(@ComSpec & " /c nslookup "&$url& " > nslookup.txt", "", @SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)


FileOpen ("nslookup.txt")
$sFileRead = FileReadLine ("nslookup.txt",5)
local $aArray = _StringBetween($sFileRead, "Address:  ", "")

msgbox(0,"Ip adres=",$aArray[0])

 

 

Share this post


Link to post
Share on other sites
Danyfirex

You could do this:

#include<array.au3>
#include <String.au3>

$url = "www.spamhause.com"

Local $iPID=Run(@ComSpec & " /c nslookup " & $url  , "", @SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)

Local $sOutput=""
While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
WEnd
Local $aIPs=StringRegExp($sOutput,'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b',3)
_ArrayDisplay($aIPs)

Saludos

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.