Sign in to follow this  
Followers 0
majnet

Is posible use standart output?

23 posts in this topic

I'd like generate some data by AutoIt and send them by pipe to another program.

Is it posible do that?

AutoIt3.exe myscript.au3 | some_program.exe

or

AutoIt3.exe myscript.au3 > out.txt

I always receive empty output.

Share this post


Link to post
Share on other sites



That's a good idea.

I tested the function ConsoleWrite with the latest beta version and it works.

Download here.

I ran my test script as follows:

%COMSPEC% /c "C:\Program Files\AutoIt3\AutoIt3.exe" C:\Test\test.au3 > C:\Test\Output.txt

Share this post


Link to post
Share on other sites

Slim, it would of been helpful to provide the test script...

Share this post


Link to post
Share on other sites

the function ConsoleWrite

Allright. Whatever makes you happy.

Script:

ConsoleWrite("Some text...")

Run this:

%COMSPEC% /c "C:\Program Files\AutoIt3\AutoIt3.exe" C:\Test\test.au3 > C:\Test\Output.txt

replace "C:\Test\test.au3" with the path to the script

replace "C:\Test\Output.txt" with the path to the output file.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you ShlimShady! It's exactly what I needed.

Edited by majnet

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I have trouble with using ConsoleWrite, because the output is buffering.

Is posible create another fuction ConsoleWriteLine, which will write one line to standard output and flush the buffer together? Or function ConsoleFlush would be helpful.

Edited by majnet

Share this post


Link to post
Share on other sites

I got a question, why does ConsoleWrite not write to the console? Load up the console (cmd.exe), navigate to a directory with a script in it that does something like ConsoleWrite("hello") and run the script by typing its name into the console window, and it runs but nothing is output to the console...

It would be cool if it did write to the console...


I have a catapult. Give me all the money or I will fling an enormous rock at your head.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Mr.Wizard, you obviously didn't read the help file. Your question is answered in bold letters (Imagine that, the help file with an answer to an obvious question!).

majnet, what exactly is the problem? I understand that it buffers, but I dont' understand where this is a problem. At some point, it does get flushed, so where does the problem lie?

Edited by Valik

Share this post


Link to post
Share on other sites

It doesn't answer the question, it says it doesn't do it. Why doesn't it do it? Wouldn't it be better if it did?


I have a catapult. Give me all the money or I will fling an enormous rock at your head.

Share this post


Link to post
Share on other sites

AutoIt is a Windows application. It does not have a console. Thus, there is no console associated with AutoIt. AutoIt does have a stdout handle which can be written to (Which is what this function does). It, however, is not possible for a console to retrieve this information any more than its possible for AutoIt to send information to it. If AutoIt were a console application, then it could, but its not, its a Windows program, so it can't. It cares not whether the application was launched from Explorer, the Run Dialog, a Windows API function directly in a third-party application or a Console window. Its all the same to a Windows application. The same holds true for a console; it doesn't care what actual subsystem the application its running uses. If its a console application, good, that means things will be set up correctly so that the application can talk to the console. If not, the console doesn't really care.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Ok, I try explain what I'm doing and why is it problem, when standard output buffers.

I try to use PSFTP, the PUTTY SFTP client, for automatically transfering files to the server. This client is operated from standard input with its commands.

My script should catch hot key Ctrl+S, which I use to save files, then find out changed files and send the commands to SFTP klient.

I try do something like this:

AutoIt3.exe myScript.au3 | psftp.exe <params_for_coneting_to_server>

The script is runing as background application. It write the command to the standard output for the SFTP client, when I'm saving the file.

However, when the output is buffers, SFTP client read out the commands after end my script :)

Edited by majnet

Share this post


Link to post
Share on other sites

Change

AutoIt3.exe myScript.au3 | psftp.exe <params_for_coneting_to_server>

To

%COMSPEC% /C AutoIt3.exe myScript.au3 | psftp.exe <params_for_coneting_to_server>

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok, I try explain what I'm doing and why is it problem, when standard output buffers.

The script is runing as background application. It write the command to the standard output for the SFTP client, when I'm saving the file.

However, when the output is buffers, SFTP client read out the commands after end my script :)

<{POST_SNAPBACK}>

why not have your AutoIt script write the info to a file and then run SFTP in your script to transfer the file ? Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Change

AutoIt3.exe myScript.au3 | psftp.exe <params_for_coneting_to_server>

To

%COMSPEC% /C AutoIt3.exe myScript.au3 | psftp.exe <params_for_coneting_to_server>

<{POST_SNAPBACK}>

I think it's the same. First code is good to write to the command line and second is for Run function in script. I used the second code in my script also. But it's not solution for my problem.

why not have your AutoIt script write the info to a file and then run SFTP in your script to transfer the file ?

<{POST_SNAPBACK}>

More easily would be start te the sctript every time when I need.

Buth the connection to the server will have slower speed do this every time.

Anyway I can do it this way. :)

Share this post


Link to post
Share on other sites

I was under the impression that piping data first ran application A and then piped the results to application B once application A terminated, not that application A pipes data to application B while application A is running. What that means is, this isn't any buffering issue or anything like that, its the way the command interpreter works.

Share this post


Link to post
Share on other sites

What that means is, this isn't any buffering issue or anything like that, its the way the command interpreter works.

<{POST_SNAPBACK}>

I don't know how is AutoIt implemented, but in C programs I can call fllush(stdout) and the output buffer is then emptied. And this wokrs when it's piping too.

Is it really no go somethin like fllush(stdout) make in AutoIt?

Share this post


Link to post
Share on other sites

Could someone plz explain what "pipe" means? maybe give an example? ...sound interesting.

Share this post


Link to post
Share on other sites

I don't know how is AutoIt implemented, but in C programs I can call fllush(stdout) and the output buffer is then emptied. And this wokrs when it's piping too.

Is it really no go somethin like fllush(stdout) make in AutoIt?

<{POST_SNAPBACK}>

I could add an implicit call to fflush(stdout) to the function, I guess. All it is is a very simple printf() wrapper.

Jon, I don't really see the point in me sending you anything over one line of code, so I'll just mention here, the next time you update can you add a fflush() after printf() in ConsoleWrite() to try to eliminate this problem?

Share this post


Link to post
Share on other sites

Jon, I don't really see the point in me sending you anything over one line of code, so I'll just mention here, the next time you update can you add a fflush() after printf() in ConsoleWrite() to try to eliminate this problem?

Added for next upload.

Share this post


Link to post
Share on other sites

Added for next upload.

<{POST_SNAPBACK}>

Thanks.

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  
Followers 0