michaelslamet Posted January 14, 2014 Share Posted January 14, 2014 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! Link to comment Share on other sites More sharing options...
Geir1983 Posted January 14, 2014 Share Posted January 14, 2014 (edited) 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 January 14, 2014 by Geir1983 Link to comment Share on other sites More sharing options...
michaelslamet Posted January 15, 2014 Author Share Posted January 15, 2014 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? Link to comment Share on other sites More sharing options...
Danp2 Posted January 15, 2014 Share Posted January 15, 2014 Why not just update your script to send an email when an error condition is detected? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
michaelslamet Posted January 15, 2014 Author Share Posted January 15, 2014 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! Link to comment Share on other sites More sharing options...
BrewManNH Posted January 15, 2014 Share Posted January 15, 2014 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 GudeHow 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 Link to comment Share on other sites More sharing options...
michaelslamet Posted January 15, 2014 Author Share Posted January 15, 2014 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 Link to comment Share on other sites More sharing options...
BrewManNH Posted January 15, 2014 Share Posted January 15, 2014 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 GudeHow 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 Link to comment Share on other sites More sharing options...
michaelslamet Posted January 15, 2014 Author Share Posted January 15, 2014 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? Link to comment Share on other sites More sharing options...
BrewManNH Posted January 15, 2014 Share Posted January 15, 2014 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 GudeHow 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 Link to comment Share on other sites More sharing options...
Unc3nZureD Posted January 15, 2014 Share Posted January 15, 2014 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 Link to comment Share on other sites More sharing options...
MHz Posted January 15, 2014 Share Posted January 15, 2014 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. Link to comment Share on other sites More sharing options...
ZacUSNYR Posted January 15, 2014 Share Posted January 15, 2014 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2014 Developers Share Posted January 15, 2014 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 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 More sharing options...
trancexx Posted January 15, 2014 Share Posted January 15, 2014 ^^ 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 Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 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 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 I was just going to delete that before anyone seen it. Poor form Meh! AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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