Executing and communicating with Perl or TCL scripts from ATEasy v8.0 using the Standard I/O Process Driver

Knowledge Base Article # Q200200

Read Prior Article Read Next Article
Summary How to use the ATEasy v8.0 Standard I/O Process Driver to control a console based application. The example uses a TCL and PERL console based interpreters to run scripts and pass data back and forth with it, using standard input and output.
ATEasy v8.0 supports calling, controlling and communicating with Windows console applications. This allows test engineers leverage existing script code written in languages such as TCL, Perl, PHP and use the script from their tests.

This article describes the simple process involved in calling a TCL and Perl script from ATEasy. The example code involves with using the ATEasy Standard I/O Process Driver StdIoProcess.drv. The example scripts will wait for ATEasy to send data via the standard I/O and then will respond by echoing this data back to ATEasy. Similar techniques can be used to control any Windows command line utilities.

The ATEasy StdIoProcess driver allows a user to call console based executable, pass arguments,monitor the process’s standard output and send data to the process via its standard input.

Note that the following software components are required to get started:
  • Microsoft .NET Framework
  • Installation of an script interpreter
  • A script interpreter executable that can take the filename of the script to be run from its first command line argument.
The first example calls a TCL script. This example is using the ActiveTCL interpreter which was installed in the C:\tcl folder.  The script will accept two numeric values and output the sum of those two values:

puts "TCL Script Started"
gets stdin x
gets stdin y
set result "The Sum is: "
append result [expr $x+$y]
puts $result

Here is the ATEasy code using the StdIoProcess driver. ATEasy pass in two numbers 4 and 5 and read back the result as calculated by the RCL script:

StdIoProcess Execute(sTclPath, "\""+sExamplePath+"StdIoProcessAdd.tcl\"", "4\r\n5\r\n", True)
s=StdIOProcess Get StdOutput()
if StdIOProcess Get ExitCode()<>0
if val(right(s, 3))<>9

Similar to the TCL interpreter, the Perl interpreter installed from Strawberry Perl can be used. In the following example we run StdIoProcessAdd.pl, passing two numbers 45 and 9 and getting back the sum as shown here:

! add two numbers using PERL
StdIoProcess Execute(sPerlPath, "\""+sExamplePath+"StdIoProcessAdd.pl\"", , False)
StdIoProcess Write("45")
StdIoProcess Write("9")
StdIoProcess Read(s, True)

The contents of the perl script TestScript.pl is the following:

print "Perl Script Started";
$x =  <STDIN>;
$y =  <STDIN>;
print $x+$y;

The referenced files are included in ATEasy v8.0 and above (see StdIoProcess.prj example). The example also contains example of executing the Windows command prompt (CMD.EXE). Here is the ATEasy form that is provided with the example:

TCL Scripting using StdIoProcess

Article Date 8/12/2010 2:51:02 PM     Updated: 8/12/2010 3:05:32 PM
Keywords Perl, TCL, PHP, ATEasy, StdIn, StdOut, Console Application, CMD.EXE

0 ratings | 0 out of 5
Read Prior Article Read Next Article