Jump to content

external command mturoute.exe, odd STDOUT stream


Recommended Posts

Iv been attempting to get the STDOUT from the little command line app mturoute.exe found Here

It acts odd because the stream does not seem to exist until the end of the output, I get a blank until its finished running and then im getting all the output data in one go ?

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GuiEdit.au3>
#include <ScrollBarConstants.au3>
    $HG_tracepath = GUICreate("TRACEPATH", 450, 355, 200, 125, -1, -1)
    $HB_tracepath_cancel = GUICtrlCreateButton("STOP", 310, 310, 137, 37, 0)
    $tcrmb = GUICtrlCreateEdit("TRACEPATH", 5, 5, 445, 300)
    GUISetBkColor(0x8899ff)
    GUISetState(@SW_SHOW)
    
$iPID = Run(@ComSpec & " /c mturoute bbc.co.uk", @TempDir, @SW_HIDE,$STDOUT_CHILD)
;~ $iPID = Run(@ComSpec & " /c tracert bbc.co.uk", @TempDir, @SW_HIDE, $STDOUT_CHILD)

    $tcrtout = ""
    $tcrcatch = ""
    While 1
        $msg5 = GUIGetMsg()
        If $msg5 = $HB_tracepath_cancel Then Exit
        $tcrtout &= StdoutRead($iPID)
        If $tcrtout <> $tcrcatch Then
            GUICtrlSetData($tcrmb, $tcrtout)
            _GUICtrlEdit_Scroll($tcrmb, $SB_PAGEDOWN)
            $tcrcatch = $tcrtout
        EndIf
        If @error Then ExitLoop
    WEnd
    Sleep(5000)

Iv checked the description and usage for the app but cant see anything to help. What am i missing ?

I have read elsewhere on the forum that some external apps do present a problem in this area but there's no harm in posting to you lot just to see ;) or maybe someone can suggest a different way of dong a TracePath on windows.

Thx all,

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

bump, im still trying & searching, the only thing i can think of is just to display "wait.." and just show the results but i dont like that idea ! how would you lot do a tracepath ?

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

I have try to increase the debugging level but same result ! Posted Image

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GuiEdit.au3>
#include <ScrollBarConstants.au3>

$HG_tracepath = GUICreate("TRACEPATH", 450, 355, 200, 125, -1, -1)
$HB_tracepath_cancel = GUICtrlCreateButton("STOP", 310, 310, 137, 37, 0)
$tcrmb = GUICtrlCreateEdit("TRACEPATH", 5, 5, 445, 300)
GUISetBkColor(0x8899ff)
GUISetState(@SW_SHOW)
$_MturoutePath = @ScriptDir & '\mturoute.exe'
$iPID = Run ( @ComSpec & ' /c "' &  $_MturoutePath & '" -d bbc.co.uk', @TempDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD ) 
$tcrtout = ""
$tcrcatch = ""

While ProcessExists ( $iPID )
    $msg5 = GUIGetMsg()
    If $msg5 = $HB_tracepath_cancel Then Exit
    $tcrtout &= StdoutRead($iPID)
    If Not @error Then
        If $tcrtout <> '' Then ConsoleWrite ( "STDOUT read : " & $tcrtout & @Crlf )
        If $tcrtout <> $tcrcatch Then
            GUICtrlSetData($tcrmb, $tcrtout)
            _GUICtrlEdit_Scroll($tcrmb, $SB_PAGEDOWN)
            $tcrcatch = $tcrtout
        EndIf
    EndIf
    $tcrterr = StderrRead ( $iPID )
    If Not @error And $tcrterr <> '' Then ConsoleWrite ( "STDERR read : " & $tcrterr & @Crlf )
WEnd

Sleep ( 5000 )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

aye ;) , thx for having a go for me. I had tried picking it apart to find where the problem is but i couldn't find it, it must be the mturoute app itself although thats odd because if the output shows on a CMD console window fine then it must have a STDOUT to pick up ?

Iv been searching for another tracepath for windows but i can only find GUI apps that are bloated for what i want and dont seem to have command line input/output anyhow.

Cheers.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Is my program the only thing that has this behavior for you? I see a tracert commented out further up, I'm assuming that worked as you expected it to?

The vile tactic that I used in this program, specifically to flummox you - is printf(). Occasionally an fprintf(stderr, "blah"); for things that are of an error-y nature. So I'm not sure what could be odd about that, unless there is some difference between how printf behaves vs cout? All the cool kids use cout these days.

If these forums have some wisdom as to that regard, shoot me an email or something and I'll see what I can do to fix it. (assuming its something on my end).

Alternatively, if there is a particular piece of data you are trying to extract I might be able to make that available better somehow.

Link to comment
Share on other sites

Hi elif,

I see your watching the net for mention of your app (i do the same ;))

wel to tell the truth Iv been ask to add this option by a large company who expressed an interest in one of my apps (speed tester), they asked for some cosmetic changes and for me to add "TracePath"

- Add button for tracepath (better than traceroute).

So as i dont use Linux i was just going to give them the standard "mturoute" output and hope that its the data that they are after

Good to here from you :)

JackDinn.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

well i was hoping that doing a search on google for "tracepath for windows" would give me an easy'ish method of doing this but iv started looking at doing it myself with

"ping www.bbc.co.uk -f -l xxxx" and changing the xxxx values i should be able to home in on the MTU, it shouldn't be to much hassle.

Although i would be interested to know if you did figure out why AI cant pick up the STDOUT stream.

Thx,

JackDinn.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

well something like this :-

#include <Constants.au3>
#include <GuiEdit.au3>
#include <ScrollBarConstants.au3>
$HG_tracepath = GUICreate("TRACEPATH", 450, 355, 200, 125, -1, -1)
$HB_tracepath_cancel = GUICtrlCreateButton("STOP", 310, 310, 137, 37, 0)
$tcrmb = GUICtrlCreateEdit("TRACEPATH", 5, 5, 445, 300)
GUISetBkColor(0x8899ff)
GUISetState(@SW_SHOW)
$tcrtout = ""
$tcrcatch = ""
$mtu_max = 10000
$mtu_min = 0
$mtu_test = 5000
$trcloc = "bbc.co.uk"
$output = "TRACEPATH" & @CRLF & @CRLF & "Host = " & $trcloc & @CRLF & @CRLF
Do
    $tcrtout = ""
    $tcrcatch = ""
    $iPID = Run(@ComSpec & ' /c ping ' & $trcloc & ' -f -l ' & $mtu_test, @TempDir, @SW_HIDE, $STDOUT_CHILD)
    While 1
        $msg5 = GUIGetMsg()
        If $msg5 = $HB_tracepath_cancel Then Exit
        $tcrtout &= StdoutRead($iPID)
        If $tcrtout <> $tcrcatch Then
            $tcrcatch = $tcrtout
        EndIf
        If @error Then ExitLoop
    WEnd
    $split = StringSplit($tcrtout, @CRLF, 1)
    $split2 = StringSplit($split[10], " ")
    $lost = $split2[14]
    If $lost > 0 Then
        $mtu_max = $mtu_test
        $mtu_test = Round($mtu_min + (($mtu_max - $mtu_min) / 2))
        $output &= 'Packet Size = ' & $mtu_max & ' ' & $split[10] & @CRLF
        GUICtrlSetData($tcrmb, $output)
        _GUICtrlEdit_Scroll($tcrmb, $SB_PAGEDOWN)
    EndIf
    If $lost = 0 Then
        $mtu_min = $mtu_test
        $mtu_test = Round($mtu_min + (($mtu_max - $mtu_min) / 2))
        $output &= 'Packet Size = ' & $mtu_min & ' ' & $split[10] & @CRLF
        GUICtrlSetData($tcrmb, $output)
        _GUICtrlEdit_Scroll($tcrmb, $SB_PAGEDOWN)
    EndIf
    If $mtu_max - $mtu_min < 2 Then
        $output &= @CRLF & $trcloc & ' MTU = ' & $mtu_min + 28 & ' bytes.'
        GUICtrlSetData($tcrmb, $output)
        _GUICtrlEdit_Scroll($tcrmb, $SB_PAGEDOWN)
        While 1
            $msg5 = GUIGetMsg()
            If $msg5 = $HB_tracepath_cancel Then Exit
        WEnd
    EndIf
Until 0

Although mturoute.exe is faster than this but the basics are just about there ;)

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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