executing python within perl script

Discussion in 'Python' started by SS, Dec 18, 2003.

  1. SS

    SS Guest

    I am trying to execute some python commands within a perl script and
    running into problems. The following works:
    python -c "import mypkg;do this; do that"
    however when I try to do something like
    #!/bin/perl -w
    ......
    ......
    $cmd = "import mypkg; do this; do that";
    $string = `python -c \"$cmd\"`;

    and execute this perl script I get error:

    Traceback (most recent call last):
    File "<string>", line 1, in ?
    File "/apps/relibase/python/reliscript/python/reliscript.py"
    , line 228, in ?
    __internal__ = internal_storage()
    File "/apps/relibase/python/reliscript/python/reliscript.py"
    , line 25, in __init__
    import re; self.re = re
    File "/apps/relibase/python/Python-2.1.1/Lib/re.py", line 28
    , in ?
    from sre import *
    File "/apps/relibase/python/Python-2.1.1/Lib/sre.py", line 1
    7, in ?
    import sre_compile
    File "/apps/relibase/python/Python-2.1.1/Lib/sre_compile.py"
    , line 15, in ?
    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
    AssertionError: SRE module mismatch
    SS, Dec 18, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TheDustbustr
    Replies:
    2
    Views:
    362
    Christian Tismer
    Aug 17, 2003
  2. sarmin kho
    Replies:
    1
    Views:
    376
    Cameron Laird
    Jun 4, 2004
  3. Replies:
    3
    Views:
    1,056
    James Stroud
    Dec 13, 2005
  4. Replies:
    3
    Views:
    186
    Josef Moellers
    Nov 1, 2007
  5. Replies:
    4
    Views:
    295
    ccc31807
    Jul 29, 2011
Loading...

Share This Page