Sign in to follow this  
Followers 0
supersonic

How to redirect error messages if running scripts from command line

8 posts in this topic

#1 ·  Posted (edited)

Hi,

for some purpose I call uncompiled scripts from command line. Therefore I use the following command:

%ComSpec% /C "C:TEMPACompiledScript.exe" /ErrorStdOut /AutoIt3ExecuteScript "C:TEMPAnUncompiledScript.au3" %1 %2 %3 %4 %5 %6 %7 %8 %9

This works quite well - even errorlevels (%ERRORLEVEL%) are returned.

Is there a way to return the debug output in case of an error as in SciTE?

Greets,

-supersonic.

Edited by Jon

Share this post


Link to post
Share on other sites



Hi,

StderrRead, StdoutRead, ConsoleRead ?

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Perhaps:

$ERRORLEVEL = RunWait("C:TEMPACompiledScript.exe" /ErrorStdOut /AutoIt3ExecuteScript "C:TEMPAnUncompiledScript.au3" %1 %2 %3 %4 %5 %6 %7 %8 %9')

msgbox(64, "", "The error level was: " & $ERRORLEVEL)
Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If I run this script:

Opt("MustDeclareVars", 1)
$test = "TEST"
MsgBox(0, "", $test)

... SciTE returns:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:UserstestDesktopAutoIt v3 Script (neu).au3" /UserParams
+>13:31:32 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0407 Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X86)
>Running AU3Check (1.54.22.0) from:C:Program FilesAutoIt3
C:UserstestDesktopAutoIt v3 Script (neu).au3(2,15) : WARNING: $test possibly not declared/created yet
$test = "TEST"
~~~~~~~~~~~~~~^
C:UserstestDesktopAutoIt v3 Script (neu).au3 - 0 error(s), 1 warning(s)
->13:31:32 AU3Check ended. Press F4 to jump to next error.rc:1
>Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "C:UserstestDesktopAutoIt v3 Script (neu).au3"
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
C:UserstestDesktopAutoIt v3 Script (neu).au3 (2) : ==> Variable used without being declared.:
$test = "TEST"
^ ERROR
->13:31:32 AutoIT3.exe ended.rc:1
>Exit code: 1 Time: 1.261

It would be nice I could get at least at the command line:

C:UserstestDesktopAutoIt v3 Script (neu).au3 (2) : ==> Variable used without being declared.:
$test = "TEST"
^ ERROR

Or comes this from SciTE?

Edited by supersonic

Share this post


Link to post
Share on other sites

This line in your script: "Opt("MustDeclareVars", 1)" tells the script that you must declare all variables. This error: "Variable used without being declared." tells YOU that you didn't declare it. Put Local or Global in front of the line: $test = "TEST" and that will make $test declared.


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 this post


Link to post
Share on other sites

#6 ·  Posted (edited)

BrewManNH,

yes, I know, this is only to force an error! :)

My question is: Must I use SciTE to receive error text messages or is it also possible to display them in a command box?

EDIT:

If I run an uncompiled script at the command line and an error occurs then only an errorlevel will be returned.

Edited by supersonic

Share this post


Link to post
Share on other sites

You must use scite for uncompiled scripts. For compiled ones, you could write the error in Command Prompt using ConsoleWrite() function.


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

MKISH,

that means error messages like this one:

"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:UserstestDesktopAutoIt v3 Script (neu).au3" /UserParams +>13:31:32 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0407 Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X86) >Running AU3Check (1.54.22.0) from:C:Program FilesAutoIt3 C:UserstestDesktopAutoIt v3 Script (neu).au3(2,15) : WARNING: $test possibly not declared/created yet $test = "TEST" ~~~~~~~~~~~~~~^ C:UserstestDesktopAutoIt v3 Script (neu).au3 - 0 error(s), 1 warning(s) ->13:31:32 AU3Check ended. Press F4 to jump to next error.rc:1 >Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "C:UserstestDesktopAutoIt v3 Script (neu).au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop C:UserstestDesktopAutoIt v3 Script (neu).au3 (2) : ==> Variable used without being declared.: $test = "TEST" ^ ERROR ->13:31:32 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 1.261

... could be only displayed by SciTE?

Am I right?

Edited by supersonic

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