run a Perl script from Python and stop it when finishes

Question:

I call and run a perl script inside a python script. It calls properly the perl script, works, but it does not stop…it seems that the perl script doesn’t stop.

How can i solve it? if I run manually the perl script alone it stops.

I use…

import subprocess

pipe = subprocess.Popen(["perl", "/home/scripts/cat.pl"])
Asked By: Enric Agud Pique

||

Answers:

Add the following line to your python program

pipe.wait()
Answered By: Shagun Sodhani

Open your Python code in your Python editor of choice.

Go to the line in the code where you want to run your Perl script.

Type "pyth.RunPerl.ext;" where "Full Path To File" is the full path filename of your Perl file. This will cause Python to execute the Perl file, then continue down the line with the rest of your Python code.

Answered By: Ankit Yadav
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.