Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run perl script with python

Tags:

python

linux

perl

I've been looking at multiple examples on here and elsewhere, but nothing seems for work for me. I know nothing about python. All I am trying to do is run a perl script simply located at

sdb1/media/process.pl

The example code that I've found runs all over the place, and mostly seems like it has extra stuff that I don't need. What I'm trying right now is

#! /usr/bin/python
pipe = subprocess.Popen(["perl", "/sdb1/media/process.pl"], stdout=subprocess.PIPE)

But that just gives me the error

NameError: name 'subprocess' is not defined

If I've missed anything important, let me know. Otherwise, thanks for your time.

like image 721
user259861 Avatar asked Mar 29 '26 21:03

user259861


1 Answers

you need to import the subprocess library to run subprocess

#! /usr/bin/python

import subprocess

pipe = subprocess.Popen(["perl", "/sdb1/media/process.pl"], stdout=subprocess.PIPE)
like image 133
smushi Avatar answered Apr 01 '26 08:04

smushi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!