• Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
  • Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
Free Edition Compatible
How to Automate Windows Command Line Operations
Objectives
In this video you'll learn HOW TO:
► Automate Windows Command Line Shell (CMD) operations
► Define and pass external parameters to your test
► Start Windows applications, CLI commands and batch files directly from your script
► Read Windows stdout into a buffer in your script
► Define EVENTS to react on messages in run-time, i.e. at a moment they appear
With this event-driven technique you'll be able to achieve a significant test time reduction.
All Tutorials
Download Your Free Edition
Sources & Resources
Hands-on ...
To do your hands-on practice more effective:
► Install the ETS Free Edition on your PC.
► Download the "Get Started" project with all up-to-date tutorial scripts.
► Unzip it to C:\ETS_Workspaces.
Sources
These scripts from the tutorial video will work with the Coronys Free Edition.
Just copy them to your ESL Edior and modify for your needs.
Run_and_Read_Stdout.esl
    Declare Status
   ; Command to run,Expected string for PASS,Wait time out
   DeclareOnce epCmd=`ver`,epExp=`C:`,epTimeout=500
   ; Start CMD process and open connection to it
   Declare PortID
   RC_CommandPortSet PortID, 'cmd.exe'
   ; Run command ('^J^M' are for '\r\n')
   RC_Send epCmd $ '^J^M', PortID  
   ; Wait for command completion
   Delay epTimeout
   ; Read Stdout to buffer
   Declare Buf
   RC_Read Buf, PortID
   ; Search for the expected string
   StrSearch Status, Buf, epExp    
   ; Check PASS/FAIL criteria  
   If Status < 0 Then ; -1 if not found
       TMMessage GT_ErrorID + 1, `Expected string not found: ` $ epExp
   Else
       TMMessage GT_InfoID + 1, `Expected string found: ` $ epExp
   EndIf   
   ; Clear ETS Terminal Window
   HBClear
   ; Display buffer data
   PrintMessage Buf    
   ; Close Connection
   RC_Close PortID
   End
Event_on_Expected.esl
   ; Command to run,Expected string for PASS,Wait time out
   DeclareOnce epCmd=`ver`,epExp=`C:`,epTimeout=500
   ; Start CMD process and open connection to it
   Declare PortID
   RC_CommandPortSet PortID, 'cmd.exe'
   ; Run command and wait for the expected string ('^J^M' are for '\r\n')
   RC_SendAndWait Status, PortID, epCmd $ '^J^M', epExp, epTimeout
   ; Check PASS/FAIL criteria  
   If Status != 0 Then ; Timeout
       TMMessage GT_ErrorID + 1, `Timeout waiting for the expected string: ` $ epExp
   Else
       TMMessage GT_InfoID + 1, `Expected string found: ` $ epExp
   EndIf   
   ; Read Stdout to buffer
   Declare Buf
   RC_Read Buf, PortID
   ; Clear ETS Terminal Window
   HBClear
   ; Display buffer data
   PrintMessage Buf    
   ; Close Connection
   RC_Close PortID
   End 
Run_Batch_File.esl
   ; Bat-file name with full path,Expected string for PASS,Wait time out
   DeclareOnce epBatFile=`FILE`,epExp=`C:`,epTimeout=500
   ; Start CMD process and open connection to it
   Declare PortID
   RC_CommandPortSet PortID, 'cmd.exe'
   ; Run batch file ('^J^M' are for '\r\n')
   RC_SendAndWait Status, PortID, epBatFile $ '^J^M', 'End of Batch', epTimeout
   ; Check if timeout expired
   If Status != 0 Then TMMessage GT_ErrorID + 1, `Out of sync`; Timeout expired
   ; Read Stdout to buffer
   Declare Buf
   RC_Read Buf, PortID
   ; Search for the expected string
   StrSearch Status, Buf, epExp
   ; Check PASS/FAIL criteria  
   If Status < 0 Then ; -1 if not found
       TMMessage GT_ErrorID + 1, `Expected string not found: ` $ epExp
   Else
       TMMessage GT_InfoID + 1, `Expected string found: ` $ epExp
   EndIf
   ; Clear ETS Terminal Window
   HBClear
   ; Display buffer data
   PrintMessage Buf
   ; Close Connection
   RC_Close PortID
   End 
  • Home
  • Products
  • Downloads
  • Tutorials
  • Contact Us
  • Terms of Use
  • Privacy Policy

Copyright © 2002-2017 Coronys Ltd. All Rights Reserved.
 
Back to top