Jump to content

stdoutread problems


Ixel
 Share

Recommended Posts

From your original post:

Did that orinially mean you saw "Progess 1%" thru "Progress 100%" show suddenly after the program completed? If not, does "shows on the console" mean you opened a CMD window, ran it, and saw that progress there while it was running? This is ceasing to make sense... :lmao:

I apologize if I am mucking things up--and I thank you for your help. I opened a CMD window, ran it, and saw that progress there while it was running. It shows the progress increments, line by line, in the CMD window.

Link to comment
Share on other sites

I opened a CMD window, ran it, and saw that progress there while it was running. It shows the progress increments, line by line, in the CMD window.

Hmm... I'm stumped. I guess that program uses a custom process to write to the console, and AutoIT's $STDOUT_CHILD doesn't hook to whatever it is. Sorry I couldn't help.

:lmao:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I apologize if I am mucking things up--and I thank you for your help. I opened a CMD window, ran it, and saw that progress there while it was running. It shows the progress increments, line by line, in the CMD window.

O.K. one last try. Execute both scripts and tell us what has happened.

MsgBox(0, "Debug", "STDOUT...")
$foo = Run(@ComSpec & " /c imagex /scroll /apply e:\jmuxpai\winxp091606.wim 1 c:","","",2+4)
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    msgbox(0,"STDOUT",$line,1)
Wend
MsgBox(0, "Debug - STDOUT", "Exiting...")oÝ÷ Ù«­¢+Ø)5Í  ½à À°ÅÕ½ÐíÕÅÕ½Ðì°ÅÕ½ÐíMQIH¸¸¸ÅÕ½Ðì¤(ÀÌØí½¼ôIÕ¸¡
½µMÁµÀìÅÕ½Ðì½¥µà½Íɽ±°½ÁÁ±äèÀäÈí©µÕáÁ¤ÀäÈíÝ¥¹áÀÀäÄØÀعݥ´ÄèÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°È¬Ð¤)]¡¥±Ä(ÀÌØí±¥¹ôMÑÉÉI ÀÌØí½¼¤(%ÉɽÈQ¡¸á¥Ñ1½½À(µÍ½à À°ÅÕ½ÐíMQIHÅÕ½Ðì°ÀÌØí±¥¹°Ä¤)]¹)5Í ½à À°ÅÕ½ÐíÕ´MQIHÅÕ½Ðì°ÅÕ½Ðíá¥Ñ¥¹¸¸¸ÅÕ½Ðì¤(

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

If yes, then you should have mentioned that! Could have saved us quite some time.

Cheers

Kurt

What would have saved time is if I would have saw this thread earlier.

Quite simply, Microsoft, as is typical, are idiots. They never call fflush() on the stream. The output builds up and is not flushed until the program closes. AutoIt shows you the output the instant it sees it, but during the entire run of the program, the ouput is buffered in imagex. By the way, you can confirm that it's not AutoIt's fault by using the command line and re-directing output to a file when using the /scroll argument. Even doing that will leave an empty file (IIRC, there is some output, but not the progress percentage). Then when the program is done, poof, magically all the data is there. Without using the /scroll argument, data is written directly to the screenbuffer and not to stdout.

So to fix this, write Microsoft and tell them they need to learn how to program. They need to flush their output streams after they write to them instead of relying on the console to do it for them (The reason you don't see this problem when running the tool in a console is because the console doesn't buffer, it writes to the screen).

Link to comment
Share on other sites

O.K. one last try. Execute both scripts and tell us what has happened.

MsgBox(0, "Debug", "STDOUT...")
$foo = Run(@ComSpec & " /c imagex /scroll /apply e:\jmuxpai\winxp091606.wim 1 c:","","",2+4)
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    msgbox(0,"STDOUT",$line,1)
Wend
MsgBox(0, "Debug - STDOUT", "Exiting...")oÝ÷ Ûú®¢×鬺1{a{béh¢¢g¬ºpÇ~׫f {(^µëçâ®ËpwhÂË!£n­©_¡ûazè·¬²)Ü­éÛ0)^¶¶Ü"Ú0²0²Ø^¢Ø^®¥~«¨µéÚ

Cheers

Kurt

Imagex does not write to STDERR, as the msgbox in the while loop did not even appear when this script ran. It seems as though imagex is locking out access to STDOUT when it is running. What do you think?

Link to comment
Share on other sites

What would have saved time is if I would have saw this thread earlier.

Quite simply, Microsoft, as is typical, are idiots. They never call fflush() on the stream. The output builds up and is not flushed until the program closes. AutoIt shows you the output the instant it sees it, but during the entire run of the program, the ouput is buffered in imagex. By the way, you can confirm that it's not AutoIt's fault by using the command line and re-directing output to a file when using the /scroll argument. Even doing that will leave an empty file (IIRC, there is some output, but not the progress percentage). Then when the program is done, poof, magically all the data is there. Without using the /scroll argument, data is written directly to the screenbuffer and not to stdout.

So to fix this, write Microsoft and tell them they need to learn how to program. They need to flush their output streams after they write to them instead of relying on the console to do it for them (The reason you don't see this problem when running the tool in a console is because the console doesn't buffer, it writes to the screen).

Ah, Valik. I was hoping you would take a look at this thread. So now I have my answer. I do appreciate everyone's help on this issue. I posted to Microsoft's feedback forum about imagex this morning. Let's see how long they take to reply--if they even decide to reply. :lmao:

Link to comment
Share on other sites

  • 5 months later...

In the interest of sharing, heres a cut&paste form a post i just made in the 911cd forums, where im working on an imagex gui, that looks suspiciously like Ghost v9:)

After struggling with the wimgapi and the obvious deficits with wimgapi needing threading and autoit not supportuing this, i decided to regress to the imagex.exe to do the imaging in my project.

After seeing this thread the other night, i thought id pop back in and post my results.

c&p:

This is just the first quick hack, and im posting it because im a little excited.....

Variable names and values arent exact and havent been changed to protect the innocent.

If you want to test it and you have AutoIT, grab the rtconsole.exe from the archive HERE and put it in the same folder as imagex, or in your path.

Obviously change the paths as well:)

Be aware that the feedback isnt exactly real time (well i wasnt doing large folders during tetsing just now, so maybe it works better on large images), but short of forking out $299 for the SmartWim or me spending the next year learning to do callbacks around MS's brain fart mentality with wimapi, i reckon this will do for a first go.

CODE

Global $line

$srcpath = "c:\program files\java"

$targetpath = "f:\win.wim"

$desc = "test"

$foo = Run(@ScriptDir & "\rtconsole.exe imagex /capture /scroll " & Chr(34) & $srcpath & Chr(34) & " " & Chr(34) & $targetpath & Chr(34) & " " & Chr(34) & $desc & Chr(34),"","",2+4)

SplashTextOn("Imagex", $line, 200, 50)

While 1

$line = StdoutRead($foo, 5)

If @error Then ExitLoop

ControlSetText("Imagex", "", "Static1", $line)

Wend

EDIT: Just tried it on something larger and it kind of peters out at @40% returns part of a string "ng" and then returns at 99%.....sheesh...but its a start........

Changing the StdoutRead($foo, 5) to other values and stringleft'ing it or trimming it is kind of flakey....

Running it with $line = StdoutRead($foo) is even worse.....

Maybe its back to square one ....sheesh..i hart Microsoft right now.............

Need sleep, ill worry about it tomorrow

Edited by frodo
Link to comment
Share on other sites

Again from that other forum, after my collapse in the early hours today due to hatred of MS, comes this to update things...........

Frodo had to collapse early this morning after going through several permutations of this progress control.

Frodo found the excitement fo getting something back from stdout intoxicating, but the excitement was short lived as it became obvious that no permutation was going to give him a 100% nice and sane output.

The closest i came to text perfection was similar to Jaque's 2nd snippet.:

$line = StdoutRead($foo)
    If @error Then ExitLoop
    If StringInStr($line,"Progress:")=1 Then
      ControlSetText("Imagex", "", "Static1", $line)
    Endif
But not finding that 100% to my exacting standards, gee who am i i kidding...umm because it was still visually a little flakey, i didnt get as far as Ixel's contribuation below. I had put my cranky pants on before i hit this stage.

Im still really nto a big fan of Ms for having to resort to such things *stomping feet*.

I used this to get a progress bar for applying an image...

Global $line
Global $line1

$foo = Run("rtconsole.exe imagex /apply c:\winre_x86\winre.wim 1 c:\winre_x86\mount2","","",2+4)
ProgressOn("Imagex", "Applying Image")

While 1
    $line = StdoutRead($foo)
    if StringInStr($line, "ImageX Tool for Windows") <> 0 then $line = 0
    if StringInStr($line, "Progress: 100%") <> 0  then ExitLoop
    $line = StringStripWS($line, 7)
    $line1 = StringSplit($line, "%")
    $line = StringRight($line1[1], 2)
    If @error Then ExitLoop
    ProgressSet($line,"","Applying Image")
Wend

ProgressOff()
Edited by frodo
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...