i trying write script opens text file contains specific lines can entered command window. instead of having user copy , paste these lines, trying use subprocess automatically make commands run. code this:
import sys tkinter import * import tkfiledialog import subprocess master = tk() master.withdraw() file_path = tkfiledialog.askopenfilename(title="open command file") print file_path open (file_path,"r") infile: cmd1 = infile.readline() cmd2 = infile.readline() cmd3 = infile.readline() cmd4 = infile.readline() p=subprocess.popen("{}; {}; {}; {}".format(cmd1, cmd2, cmd3, cmd4), stdout=subprocess.pipe) line in p.stdout: print line p.wait() print p.returncode print 'complete' the text file user selects has 4 commands similar following:
program.exe commanduniquetoprogram "c:\\...." "c:\\...."
i don't know how command line works, if run in command window, should without opening program. now, when run program thing seems work first part program.exe opens program throws strange error. instead, if line pasted command window, program not open @ , job, leads me believe subprocess doesn't spaces in command line.
any appreciated have no experience subprocess module!
Comments
Post a Comment