# Get all of scite output (including ConsoleWrite) from compiled script

## Recommended Posts

Some of my compiled scripts (compiled as GUI application) print a lot of debug information on screen

using ConsoleWrite. This is a great help when running them from SciTe.

Those scripts are running silently on the headless server. Most of the time, when those scripts running

not properly, I wont know until few days or even few weeks. This is bad.

I am thinking if those scripts can email me the SciTe output, I will know immediately when

something goes wrong.

How to read the scite output from a compiled script?

If this is not possible, I'm going to add addtional lines to save those output into a variable.

Thanks a  bunch!

##### Share on other sites

Local $data While True$data &= ConsoleRead()
If @error Then ExitLoop
Sleep(25)
WEnd

From the documentation, didnt test it but seems what you need

Edited by Geir1983

##### Share on other sites
Local $data While True$data &= ConsoleRead()
If @error Then ExitLoop
Sleep(25)
WEnd

From the documentation, didnt test it but seems what you need

Hi Geir1983,

Unfortunetely not

Result in nothing:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
ConsoleWrite("line 1" & @CRLF)
ConsoleWrite("line 2" & @CRLF)

msgbox(0,0,ConsoleRead())

So this is not possible?

##### Share on other sites

Why not just update your script to send an email when an error condition is detected?

##### Share on other sites

Why not just update your script to send an email when an error condition is detected?

Hi Danp2,

With my condition, this is not possible with some scripts, so I dont prefer this.

On my first post: "If this is not possible, I'm going to add addtional lines to save those output into a variable.",

this approach has a weakness which is it will not log output from include files.

So I think if we can read the SciTe output, it will be the best!

##### Share on other sites

Instead of using ConsoleWrite, send the messages to a text file instead, then read the text file. Reading information your script is passing to the console instead of doing it the right way is just making much more work for yourself than you should be doing. Think smarter by thinking about it the right way.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Instead of using ConsoleWrite, send the messages to a text file instead, then read the text file. Reading information your script is passing to the console instead of doing it the right way is just making much more work for yourself than you should be doing. Think smarter by thinking about it the right way.

I can do it with my scripts, but I would like to log also output from include files.

I cant modified all of those include files to output the log to a text file, that is why I am thinking if I could read the SciTe output pane it will be great

##### Share on other sites

Why can't you modify them? If you have the files, you can modify them to your needs. If they're standard include files just copy them to your script directory and rename them so you're not modifying the normal UDF files. Just make sure you're not including both the normal and modified files in the same script though.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Why can't you modify them? If you have the files, you can modify them to your needs. If they're standard include files just copy them to your script directory and rename them so you're not modifying the normal UDF files. Just make sure you're not including both the normal and modified files in the same script though.

Because they are a lot

I'm thinking if we can read through the output pane, why not we take that "easy" way.

So, it's firm that not possible for compiled script to read the output pane?

##### Share on other sites

There is no output pane on a compiled script, you're not running it in Scite so what are you trying to read from? You can always redirect the output to a file when you start the program using the old DOS style command structures of myprogram.exe>"sometextfile.txt"

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Why don't you open all of them, CTRL+H Change ConsoleWrite -> ConsoleLog

And before all the other includes you can include your own ConsoleLog() Function which auto-writes to text file instead of the console. If I'm right you can't catch consolewrites, since it's for Console based scripts instead of your current GUI based

##### Share on other sites

Scite output pane and executable, very strange. That can work but very inefficient to get current output. Press Shift + F5 to clear output pane. Type "pathtoscript.exe" in output pane and then press return. ConsoleWrites will show in output pane.

"path\to\script.exe"

.
A better way is to do as BrewManNH suggests and redirect the stdout to file. If you used ConsoleWriteError as well then also get the stderr stream. So at a command prompt you would type

"path\to\script.exe" > logfile.txt 2>&1

.
Another way is to use more at a command prompt to get the stdout, i.e type "pathtoscript.exe" | more.

"path\to\script.exe" | more

.
If you are using shortcuts to run the executables, then you could change the target to cmd /c "pathtoscript.exe" > logfile.txt 2>&1.

cmd /c "path\to\script.exe" > logfile.txt 2>&1

.
Last, you could update your scripts to use eventlog with _EventLog__Report for errors or use log files using FileWrite or the standard UDF _FileWriteLog.

The idea of using Scite for compiled scripts could be considered as shameful.

Note: You can get consolewrites from a gui application just as you do when running a script with AutoIt3.exe through Scite.

##### Share on other sites

Whenever I do command line tools, I pass the output text to a helper function and then from their I can console output it, and outputting it to a file later on is only one line inside one function.

##### Share on other sites

There is no output pane on a compiled script, you're not running it in Scite so what are you trying to read from? You can always redirect the output to a file when you start the program using the old DOS style command structures of myprogram.exe>"sometextfile.txt"

Don't you need to  compile the script with the #AutoIt3Wrapper_Change2CUI=Y parameter to create a CUI program for the Pipe stuff to work?

Jos

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

^^ No you don't.

michaelslamet, you can do it like this... Don't run compiled script directly, run it with some other script (compiled or not) which looks like this:

Local $hResourcesExe = Run("YourCompiledScript.exe", "", @SW_SHOWDEFAULT, 6);$STDERR_CHILD + $STDOUT_CHILD Local$sLine, $sLineError While 1$sLineError = StderrRead($hResourcesExe) If @error Then ExitLoop If$sLineError Then
EmailThisError($sLineError) EndIf$sLine = StdoutRead($hResourcesExe) If @error Then ExitLoop If$sLine Then
EmailThisInfo($sLineError) EndIf Sleep(100) WEnd Func EmailThisError($sText)
; Some function that will send e-mail, or in this case:
ConsoleWriteError("!ERROR TEXT: " & $sText & @CRLF) EndFunc Func EmailThisInfo($sText)
; Some function that will send e-mail, or in this case:
ConsoleWrite(">INFO: " & $sText & @CRLF) EndFunc . eMyvnE #### Share this post ##### Link to post ##### Share on other sites Or ... Local$hResourcesExe = Run("YourCompiledScript.exe", "", @SW_SHOWDEFAULT, 6); $STDERR_CHILD +$STDOUT_CHILD
Local $sLine,$sLineError

While ProcessExists("YourCompiledScript.exe")
WEnd

$sLineError = StderrRead($hResourcesExe)
EmailThisError($sLineError)$sLine = StdoutRead($hResourcesExe) EmailThisInfo($sLineError)

Func EmailThisError($sText) ; Some function that will send e-mail, or in this case: ConsoleWriteError("!ERROR TEXT: " &$sText & @CRLF)
EndFunc   ;==>EmailThisError

Func EmailThisInfo($sText) ; Some function that will send e-mail, or in this case: ConsoleWrite(">INFO: " &$sText & @CRLF)
EndFunc   ;==>EmailThisInfo

Monkey's are, like, natures humans.

##### Share on other sites

I was just going to delete that before anyone seen it.

Poor form

Meh!

Monkey's are, like, natures humans.

## Create an account

Register a new account