The ability to call and re-use existing code can save a developer time and money. LabVIEW gives users the ability to directly access and integrate code written in a variety of languages. This article explains how to re-use test scripts developed in either the Perl or Python scripting languages using the System Exec VI in LabVIEW.Perl and Python are high-level programming languages that use an interpreter to translate the source code into an executable format at run time instead of being pre-compiled. An interpreter, such as ActivePerl or ActivePython, is necessary to execute this translation.
Calling the interpreter can be simplified by changing the Environment Path Variable to include the location where your interpreter and corresponding library files are saved. You can edit the Environment Path using the System Properties Editor. You will need to ensure that the Environmental Path Variable is modified to include the directory in which the Interpreter and corresponding library files are located in order for the machine to recognize the Perl and Python tokens as commands to use the interpreter.
Note: This example was prepared using the Using the ActivePerl 5.10.0 Interpreter and the ActivePython 2.6.1 Interpreter, which can be downloaded from the External Link: APSN ActivePerl Website and External Link: ActiveState ActivePython Website, respectively. Both Installers have built in functionality to edit the Environmental Path Variable to include the directory location of the interpreter and corresponding library files.
For Perl scripts, use: 'perl scriptName.pl argument' as shown in the image below.
For Python scripts, use: 'python scriptName.py argument' as shown in the image below.
In LabVIEW you can use the System Exec.vi to execute a system-level command line that can include any parameters supported by the application you want to launch. This VI can be used to call a command line argument that will launch the Perl or Python script. Ensuring that your Environment Path Variable includes the directory in which you Interpreter and corresponding library files are saved will allow any System Exec call to recognize the perl and python tokens as commands to use the Perl and Python Interpreters to execute the script.
To call a Perl or Python script from LabVIEW you will need to pass in the following parameters to the System Exec.vi
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.