Avatar of ambuli
ambuli
Flag for United States of America asked on

Perl: executing a python script from perl program

Hi Experts,

I need to somehow use a python script in a perl program.  I don't know python, so I cannot write the entire thing in python.  But, I want to use a python script that was written by someone else.

The python script accepts one input.

How can I do it?
Microsoft DOSPerl

Avatar of undefined
Last Comment
ambuli

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
brutaldev

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mrjoltcola

Or, similar to brutaldev's suggestion, call it with backticks to read the output of the Python script.

my $s = `myscript.py foo bar`;
print "Script returned $s";

ambuli

ASKER
Thank you very much.  One small question.  The system call does not take $inputfile as an argument to the script. Also, I had to remove the " " around $Python $PyScript.
What could be wrong.

...
foreach $inputfile (@inputfiles)
{
    chomp($inputfile);
    system($Python $PyScript, $inputfile ) == 0 or die "Could not execute script.";
}
ambuli

ASKER
If the argument is filenameone, it should be passed as it is. Not "filenameone".
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
mrjoltcola

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ambuli

ASKER
Thank you.