labview和python脚本_Call Perl and Python Scripts from LabVIEW

Calling the Script Interpreter

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.

Right-click on My Computer  and select Properties.

Select the Advanced tab.

Click Environment Variables.

In System Variables, select the Path variable, and then click Edit.

Add the directory for where your Interpreter is saved.

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.

Calling Perl and Python Scripts From the Command Line

Select Start»Run

Enter cmd to launch the command line

Navigate to the directory where the Perl or Python script is saved

To call the interpreter that will execute the script use the following command(s):

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.

Calling Perl and Python Scripts from LabVIEW

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

command line: indicates the command LabVIEW calls to run a program. If the executable is not in a directory listed in the PATH environment variable, the command line must contain the full path to the executable.

working directory: the file system directory from which you want to execute the command.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值