jueves, 9 de junio de 2016

run a python script from another python script

Short Post*

To open another script from a script the following comand could be works
 In this case, the script will execute it 6 times, change the number in while 


import subprocess
cmd = 'python script.py'
i=0

while i < 6:
    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)
    i = i + 1


0 comentarios:

Publicar un comentario