Jump to content

StdoutRead Assistance


 Share

Recommended Posts

Can someone please tell me why my ping output is different at times. sometimes I get the workstation name and ip which is what I want, and sometimes I get the transmission time data.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 (BETA)
; Author:        A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------

#include <Constants.au3>
#include <File.au3>
#NoTrayIcon

$file = FileOpen("sms2k3clientrepair_systems.inf", 0)

; --------Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
If @error = -1 Then ExitLoop

    $ping = Ping( $line ,250)

Select

    Case $ping = 0

;MsgBox(0,"here you go", "Error")

        _FileWriteLog(@TempDir & "\sms2k3clientrepair\SMS2K3ClientRepair.log", "Unable to ping " & $line & " - Ping Workstations")

    Case $Ping = 1

    $run = Run(@ComSpec & " /c ping " & $line, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1
        $line2 = StdoutRead($run)

    If @error = -1 Then ExitLoop

        If StringInStr($line2, "Reply from") Then

            $temp = $line2

            $temp = StringTrimLeft($temp,11)

            $temp = StringTrimRight($temp,2)

            ProcessClose("ping.exe")

;           MsgBox(0,"here you go", $temp)
    _FileWriteLog(@TempDir & "\sms2k3clientrepair\SMS2K3ClientSuccess.log", $line & "    " & $temp)
;_FileWriteLog(@TempDir & "\foundIPs.log",  $line & " " & $temp)
    EndIf
Wend
EndSelect
Wend

SAMPLE RESULTS

2005-10-28 08:27:49 : REWW0102 162.87.109.209: bytes=32 time<1ms TTL=127

2005-10-28 08:27:50 : REWW0038 162.87.68.167

2005-10-28 08:27:50 : REWW0062 162.87.109.38

2005-10-28 08:27:50 : REWW0009 162.87.109.151

2005-10-28 08:27:51 : REWW0058 162.87.109.108

2005-10-28 08:28:15 : NTRL2497A 162.87.66.255: bytes=32 time<1ms TTL=127

2005-10-28 08:28:18 : NTRL5076 162.87.64.255

2005-10-28 08:28:23 : NTRW3515 162.87.33.85

2005-10-28 08:28:42 : NTRL5028 162.87.65.97

Any assistance would be greatly appreciated
Link to comment
Share on other sites

  • Developers

Can someone please tell me why my ping output is different at times. sometimes I get the workstation name and ip which is what I want, and sometimes I get the transmission time data.

Any assistance would be greatly appreciated

I would first give Ping the time to generate its output before starting to process it. There a big chance now that not all data you need is there yet.......

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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