Author Topic: Command Line Processing  (Read 3670 times)

Offline mchtower

  • Newbie
  • *
  • Posts: 22
When working from the command line is there is a way to detect errors? In others words if I have a batch file that executes multiple scripts using sccui.exe

sccui.exe -script z:\local_scripts\accelerated.xml -exit -sdtl
sccui.exe -script z:\local_scripts\accelerated2.xml -exit -sdtl

Is there a way to tell of instance accelerated.xml failed before I run accelerated2.xml?

Offline fwilson

  • Hero Member
  • *****
  • Posts: 779
mchtower,

You could add the parameter to halt test on failure to the beginning of each script. This would cause testing to stop in its tracks when an error is encountered.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<Script haltonresults="FAIL">
        <TestSet>
   
This may or may not be exposed in the script editor so you may have to put it in in a standard text editor.

-Fred
“Integrity is doing the right thing, even if nobody is watching.”  ~ J.C. Watts

Offline mchtower

  • Newbie
  • *
  • Posts: 22
Fred,

Thanks for your reply. That almost accomplished what I'm trying to do. Adding that code tp the beginning of accelerated.xml stops script execution when an error is found. However, accelerated2.xml is still executed and stopping that from happening is the second part of what I need to do.

Offline fwilson

  • Hero Member
  • *****
  • Posts: 779
mchtower,

I see what you are trying to do.  Let me ask around and see what I can come up with. I'm pretty sure there is a way to accomplish that.

-Fred
“Integrity is doing the right thing, even if nobody is watching.”  ~ J.C. Watts

Offline fwilson

  • Hero Member
  • *****
  • Posts: 779
mchtower,

Since the Batch file has ultimate control of the process the "smarts" would have to be built into it.  You can parse a text file from within a DOS batch file using the findstr command.  You could then exit the Batch file if the string FAILED is found in the logfile stopping any further execution.  Here is something I cobbled together to do such a thing:

@echo off
echo running 1st script
findstr /m "FAILED" c:\testlog.txt
if %errorlevel%==0 goto FAIL
echo running 2nd script
findstr /m "FAILED" c:\testlog2.txt
if %errorlevel%==0 goto FAIL
echo running 3rd script
findstr /m "FAILED" c:\testlog3.txt
if %errorlevel%==0 goto FAIL
echo All Passed
goto END
:FAIL
echo TEST FAILED
:end

This batch file will stop execution if FAILED is found in the referenced text file.

Here is an example of the findstr command:
http://www.computerhope.com/issues/ch001102.htm

Hope this helps.

-Fred

« Last Edit: January 29, 2010, 09:51:40 am by fwilson »
“Integrity is doing the right thing, even if nobody is watching.”  ~ J.C. Watts

Offline mchtower

  • Newbie
  • *
  • Posts: 22
Fred,

That is EXACTLY what I needed, thanks!

Offline fwilson

  • Hero Member
  • *****
  • Posts: 779
mchtower,

You are most welcome.

-Fred
“Integrity is doing the right thing, even if nobody is watching.”  ~ J.C. Watts