I've got a Perl script that I want to invoke from a Python script. I've been looking all over, and haven't been successful. I'm basically trying to call the Perl script sending 1 variable to it, but don't need the output of the Perl script, as it is a self contained program.
What I've come up with so far is:
var = "/some/file/path/"
pipe = subprocess.Popen(["./uireplace.pl", var], stdin=subprocess.PIPE)
pipe.stdin.write(var)
pipe.stdin.close()
Only just started Python programming, so I'm sure the above is total nonsense. Any help would be much appreciated.
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.
Just do:
var = "/some/file/path/"
pipe = subprocess.Popen(["perl", "uireplace.pl", var])
If you just want to open a pipe to a perl interpreter, you're on the right track. The only thing I think you're missing is that the perl script itself is not an executable. So you need to do this:
var = "/some/file/path/"
pipe = subprocess.Popen(["perl", "./uireplace.pl", var], stdin=subprocess.PIPE)
pipe.stdin.write(var)
pipe.stdin.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With