[Python] How to obtain output from external progam and put it into a variable in Python

Discussão em 'Python' iniciado por Stack, Junho 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am still fairly new to the python world and know this should be an easy question to answer. I have this section of a script in python that calls a script in Perl. This Perl script is a SOAP service that fetches data from a web page. Everything works great and outputs what I want, but after a bit of trial and error I am confused to how I can capture the data with a python variable and not just output to the screen like it does now.

    Any pointers appreciated!

    Thank you,

    Pablo

    # SOAP SERVICE
    # Fetch the perl script that will request the users email.
    # This service will return a name, email, and certificate.

    var = "soap.pl"
    pipe = subprocess.Popen(["perl", "./soap.pl", var], stdin = subprocess.PIPE)
    pipe.stdin.write(var)
    print "\n"
    pipe.stdin.close()

    Continue reading...

Compartilhe esta Página