Jump to content
Sign in to follow this  
rone

Standard Input/Output

Recommended Posts

rone

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!

Share this post


Link to post
Share on other sites
rone

Yes!! 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 by rone

Share this post


Link to post
Share on other sites
evilertoaster

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?

Share this post


Link to post
Share on other sites
rone

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.

Share this post


Link to post
Share on other sites
evilertoaster

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=47809

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

Share this post


Link to post
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
Sign in to follow this  

×