Jump to content

nslookup works but not in my other script! pls help


farma
 Share

Recommended Posts

Hi,

I optimized a script from Simeon for Non-interactively renames an XP computer to its DNS hostname, to check nslookup (pc-name and ip, ip and pc-name)

It is working fine but i cannot put it in my other script, I always get an error at Func _Die_Message ($msg)

It must be a problem because i use #Include <GUIConstants.au3> and #include <Constants.au3> in the other script.

Can someone please help me?

I want to use it to check if a printer is in the dns, the script where i want to use the nslookup is attached

Here is the nsloockup script:

Global Const $DS_SETFOREGROUND      = 0x00000200
Global Const $WS_EX_TOPMOST         = 0x00000008
Global Const $WS_CAPTION            = 0x00C00000
GUICreate("Checking NSlookup", 300, 170, 100, 100, BitOr($DS_SETFOREGROUND, $WS_CAPTION), $WS_EX_TOPMOST )
GUICtrlCreateLabel("This Script takes a while", 30, 20)
$infotext = GUICtrlCreateLabel("", 30, 60, 340, 40)
GUISetState(@SW_show)
$filename =  @TempDir & "\nslookup" & @MIN & @SEC & ".txt"
$filename1 =  @TempDir & "\nslookup" & @MIN & @SEC & "1.txt"
If FileExists($filename) Then 
    If NOT FileDelete($filename) Then
        _Die_Message('Error: problem deleting pre-existing file "' &$filename & '"!')
    EndIf
EndIf
If FileExists($filename1) Then 
    If NOT FileDelete($filename1) Then
        _Die_Message('Error: problem deleting pre-existing file "' &$filename1 & '"!')
    EndIf
EndIf
$PCname = "www.t-online.de"
_Message('Performing nslookup to check' & @LF & 'if DNS is ok for:"' & $PCname & '"')
$nslookup =  @WindowsDir & '\System32\nslookup.exe -retry=10'
$ping1 = @WindowsDir & '\System32\ping.exe -w 20 -n 1'
$commandline = @ComSpec & ' /A /C "' & $nslookup & '" ' & $PCname & ' > ' & $filename
RunWait($commandline)
$commandline1 = @ComSpec & ' /A /C "' & $ping1 & '" ' & $PCname & ' > ' & $filename1
RunWait($commandline1)


$filehandle1 = FileOpen($filename1, 0)
If $filehandle1 = -1 Then
    _Die_Message('Error: unable to open file "' & $filename1 & '"')
EndIf
$computername1 = "invalidtoomanycharactersforastart"
Do
    $line1 = FileReadLine($filehandle1)
    If @error = -1 Then
       _Die_Message('Error: error parsing file "' & $filename1 & @LF & '"')
    EndIf
    If StringInStr($line1, "Antwort") Then
        $line1 = StringStripWS($line1, 9 )
        $line1 = StringReplace($line1, "Antwort" & "von", "")
        $splitline1 = StringSplit( $line1, ":")
        If $splitline1[0] < 2 Then
            _Die_Message('Error: Computername value from "' & $filename1 & '" is empty!' & @LF & ' Computername left unchanged.')
        Else
            $computername1 = $splitline1[1]
            _Message('Using IP: "' & $computername1 & '"')
        EndIf
    EndIf

Until $computername1 <> "invalidtoomanycharactersforastart"
FileClose($filename1)

$filehandle = FileOpen($filename, 0)
If $filehandle = -1 Then
    _Die_Message('Error: unable to open file "' & $filename & '"')
EndIf
$computername = "invalidtoomanycharactersforastart"
Do
    $line = FileReadLine($filehandle)
    If @error = -1 Then
        _Die_Message('Error: error parsing file "' & $filename & @LF & '"')
    EndIf
    If StringInStr($line, "Name:") Then
        $line = StringStripWS($line, 8 )
        $line = StringReplace($line, "Name:", "")
        $computername = $line
        _Message('Using Computername "' & $computername & '"')
    EndIf

Until $computername <> "invalidtoomanycharactersforastart"
FileClose($filename)

If $PCname = $computername then
Msgbox(0,"Status","NSlookup is ok for" & @LF & $computername, 3)
FileDelete($filename)
FileDelete($filename1)
ENDIF

; Declare functions used above.
Func _Die_Message ($msg)
    _Message($msg)
    Exit(1)
EndFunc

Func _Done_Message ($msg)
    _Message($msg)
    Exit(0)
EndFunc

Func _Message ($msg)
    ConsoleWrite($msg & @LF)
    GUICtrlSetData($infotext, $msg)
    Sleep(5000)
EndFunc

Toolbox_Final.au3

Link to comment
Share on other sites

Hi,

I tried both scripts and they worked. Besides (nice scripts) :lmao:

I included the first scipt in your script. I made a Func out of the nslookup part of the first and started your script --- it works.

Where is your problem? What do you want to do in your script exactly?

GERMAN:

Was willst du den genau in deinem Script machen? Wie und vor allem wo willst du die nslookup Funktionalität den einbauen?

Gruß und 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

Hi,

I tried both scripts and they worked. Besides (nice scripts) :lmao:

I included the first scipt in your script. I made a Func out of the nslookup part of the first and started your script --- it works.

Where is your problem? What do you want to do in your script exactly?

GERMAN:

Was willst du den genau in deinem Script machen? Wie und vor allem wo willst du die nslookup Funktionalität den einbauen?

Gruß und so long,

Mega

I want to checkt a Printer if Ping is ok / nslookup is ok and if directprint is ok.

Can you pls tell me what to do to get these scripts working?

GERMAN:

Der NSlookup soll unter $druck

Er soll schaun, ob der Drucker im DNS ok ist auch wenn er nicht pingbar sein sollte.

Edited by farma
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...