Jump to content

Is posible use standart output?


majnet
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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. :)

Link to comment
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.

Link to comment
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?

Link to comment
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?

Link to comment
Share on other sites

  • Administrators

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