Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-07-2009
Member
 
Join Date: May 2008
Posts: 37
How to call perl script from Python?

How to call perl script from Python?

I am new with Python.
I want to know If I can run a Perl script from Python? Please give me an example for doing this if its possible?

Thanks in advance.
Reply With Quote
  #2  
Old 23-07-2009
Member
 
Join Date: Apr 2008
Posts: 46
Re: How to call perl script from Python?

Hi,

Do you have installed Perl engine & Python? Only python can't parse perl script.
If yes then its really easy. GO ahead.
Reply With Quote
  #3  
Old 23-07-2009
Member
 
Join Date: May 2008
Posts: 37
Re: How to call perl script from Python?

Actually what I want to do is, pipe an email text which is in a tring to the perl script & store the result in another variable. IS this possible? Please let me know how to do so?

Can I use OS.system for this I hope I can but not sure actually.

My system only have Python.
Reply With Quote
  #4  
Old 23-07-2009
Member
 
Join Date: May 2008
Posts: 38
Re: How to call perl script from Python?

Use subprocess. Here is the Python script:

Code:
#!/usr/bin/python

import subprocess

var = "hello"

pipe = subprocess.Popen(["./x.pl", var], stdout=subprocess.PIPE)

result = pipe.stdout.read()

print result
And here is the Perl script:

Code:
#!/usr/bin/perl

use strict;
use warnings;

my $name = shift;

print "hello $name!\n";
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to call perl script from Python?"
Thread Thread Starter Forum Replies Last Post
Perl VS Python Trance Maniac Software Development 6 06-10-2010 11:01 PM
Is it possible to execute Perl script within another script? RasMus Software Development 2 21-07-2009 10:57 PM
Need Perl script to execute from another. beelow Software Development 2 20-06-2009 09:17 AM
Training on scripting languages perl,python,Tcl/Tk in Mumbai jagori566 Education Career and Job Discussions 2 20-05-2009 06:43 PM
Title of a Perl CGI script !const Software Development 2 26-03-2009 11:43 PM


All times are GMT +5.5. The time now is 06:04 AM.