rone Posted October 8, 2007 Share Posted October 8, 2007 What is the "best" way to pipe standard input into an AutoIt-based command line filter and then pipe the results to standard out? Thanks! Link to comment Share on other sites More sharing options...
evilertoaster Posted October 8, 2007 Share Posted October 8, 2007 Like in this post?-http://www.autoitscript.com/forum/index.php?showtopic=43777 Link to comment Share on other sites More sharing options...
rone Posted October 8, 2007 Author Share Posted October 8, 2007 (edited) Like in this post?- http://www.autoitscript.com/forum/index.php?showtopic=43777Yes!! When I run the following script from that post, standard input works fine. $Pipe = "" Do $Pipe &= ConsoleRead() Until @error MsgBox(0, "ReadPipe", "Data: " & @CRLF & $Pipe)oÝ÷ Ø izwbayú%"h¶nÞ±Êâ¦×hzÉ趦ëm¢Ø^ä°whÁ«Â¥v¯yìiyË^u«¢+Ù ½¹Í½±]É¥Ñ ÀÌØíA¥Á¤ However, if the calling batch file pipes the results of the AutoIt script to "more.exe", it does display in the DOS window. Edited October 8, 2007 by rone Link to comment Share on other sites More sharing options...
evilertoaster Posted October 8, 2007 Share Posted October 8, 2007 humm still not 100% sure what your talking about... Perhaps you were expecting the ConsoleRead() to keep the data in the buffer? If that's the case you need to set it to only 'peek' at the data not read it... Can you make a code snippet to examplify what you mean exactly? Link to comment Share on other sites More sharing options...
rone Posted October 9, 2007 Author Share Posted October 9, 2007 humm still not 100% sure what your talking about... Perhaps you were expecting the ConsoleRead() to keep the data in the buffer? If that's the case you need to set it to only 'peek' at the data not read it... Can you make a code snippet to examplify what you mean exactly?What I am trying to do is to read the standard input, extract a substring with known position and length, and output the substring with a behavior consistent with that of say the "find" DOS command, which allows the standard output to be piped to yet another command or be output directly to the DOS window if there are no other commands. You can accomplish the substring extraction in DOS using I/O redirection and the "set" command a couple of times, but the syntax is convoluted and I wanted to use a simpler form. So, I decided to see what AutoIt could do. The substring AutoIt code snippet is as follows: Do $Pipe &= ConsoleRead() Until @error $Pipe = StringMid( $Pipe, 44, 15 ) ConsoleWrite( $Pipe ) Then, for example, consider an invoking batch file as follows: ipconfig | find "IP Address. ." | substring.exe This produces no output to the DOS window. However, the following batch file outputs the correct host IP address substring to the DOS window: ipconfig | find "IP Address. ." | substring.exe | more Is this the expected/desired behavior? I was surprised that the "more" command was needed to see the output in the DOS window. I just want to make sure that I am not missing something here. Link to comment Share on other sites More sharing options...
evilertoaster Posted October 9, 2007 Share Posted October 9, 2007 o I get ya....well 1st look in the help file at the ConsoleWrite() function-You'll see at the bottom in nice big bold letters-This does not write to a DOS console.Reason? Becuase autoit isn't compiled as a console application (its a GUI app).Now if you take a look at this post in the developer forum-http://www.autoitscript.com/forum/index.php?showtopic=47809they show how to use editbin to change a few bytes and make the applicatino a console app. After you do that, consolewrite() should work like you thougt it should. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now