LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling perl script from labview

Hi,
 
I have a perl script and I would like to call the perl script from Labview
anyone can help me with that?
 
I used system exec but I'm getting an error.
Anyone have a working example like calling a simple perl script from Labview.
 
Thanks
SL Ong
0 Kudos
Message 1 of 16
(5,111 Views)
Did you protorype the ssytem exec on the command line prompt to verify that the command is the correct system exec?  What error do you get? 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 16
(5,095 Views)
This is the error that I get
 
GetConsoleMode failed, LastError=|6| at C:/Perl/site/lib/Term/ReadKey.pm line 264.
 
but it's ok when I run at the command prompt.
0 Kudos
Message 3 of 16
(5,085 Views)
Could you post the actual command are you giving System Exec? 
0 Kudos
Message 4 of 16
(5,072 Views)

Some things to consider (I dont do perl) the error seems to be related to not running in a console.  Try using wait for completion = True and wire up the standard input.  This is just a guess since I dont know anything about the script.  I have had some decent luck with the command line prompt in the past.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 16
(5,060 Views)
Readkey is used for simple terminal control. Evidently when labview takes over control it removes some of the controls the perl script needs to control the keyboard. I suggest you start a dos session that invokes the perl script. This in turn should open up a separate dos window that the perl script can grab control of.
 
Could you specify the string you used when you invoke the perl script.
0 Kudos
Message 6 of 16
(5,048 Views)

Hi,

Thanks for the reply from everyone.

The attached is my code to call Perl script and after calling this, I need to query the Perl Script by sending command like @help. Do they have a way to query the Perl script by sending command like @help and get the return result. 

I think Joseph you are right, but how do I get the return result if I invoke it in a separate dos session.

SL Ong

0 Kudos
Message 7 of 16
(5,024 Views)
Hi SL Ong,
 
Thanks for contacting National Instruments.  That definitely sounds like a good idea and path that you are heading down right now.  I am not much of a Perl expert either, but I agree with what was said earlier in this thread where setting the "Wait for Completion" input to True is a good way to go when using System Exec.  I hope you are able to get some more input about the actual Perl script soon and good luck with your application!
Regards

Noah R
Applications Engineering
National Instruments
0 Kudos
Message 8 of 16
(4,992 Views)
Try piping the results to a file. When it completes, read the results from the file.
0 Kudos
Message 9 of 16
(4,979 Views)

Hi,

Yeah, I already tried that but I can't get the script working when called from Labview,

it still give out the error. Anyway, can National Instrument develope something to interface with a Perl script like

a Mathlab node? It could help a lot of people out there, I guess.

But, at the moment, how can I get the script run in command prompt but with Labview running at the background

emulating the keyboard and retrieving the command prompt output? Is that possible?

 

0 Kudos
Message 10 of 16
(4,967 Views)