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
; 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
; 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
Copyright © 2002-2017 Coronys Ltd. All Rights Reserved.
|