Results 1 to 4 of 4

Thread: How to call perl script from Python?

  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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";

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,241,683.33317 seconds with 16 queries