Hack Forums
[Python] [SOLVED] Using Python to Control another Python script? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] [SOLVED] Using Python to Control another Python script? (/showthread.php?tid=5599681)



[SOLVED] Using Python to Control another Python script? - TheWarOwl - Apr 14, 2017

NEVERMIND! Here's a working example for anyone interested:

PHP Code

<?php 
import subprocess
cmd 
= 'script.py' #How I'd start the script in cmd

p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
out, err = p.communicate() 
result = out.split('\n')
for 
lin in result:
    if 
not lin.startswith('#'):
        print(
lin) 



* - SIM-1866423 - Apr 14, 2017

Best way always import files.


* - TheWarOwl - Apr 14, 2017

(Apr 14, 2017 10:59 AM)Mnemosyne Wrote:  Best way always import files.

Yes however I need the output - or what it's printing. I could rewrite the old code but that would take forever


* - SIM-1866423 - Apr 14, 2017

(Apr 14, 2017 11:21 AM)Piero-Bird Wrote:  Yes however I need the output - or what it's printing. I could rewrite the old code but that would take forever

I'm struggling to understand, you can still use variables to do that.Or basically just return things