0
Subprocess can open a program, but how can i get its output file path?
I'm trying to open a program in Windows, use said program to create a save file, then get the filepath for further modifications. I have a code I'm working on called craftauto in my codes. would someone familiar with subprocess' take a look at it and tell me what I'm doing wrong?
10 Réponses
+ 3
7: print("stdout: %r\nstderr: %r" % (stdout_text, stderr_text))
Drop the _text, use stdout, stderr
Later, you call subprocess.stuff but you're using "from subprocess import Popen,PIPE
", so only those bits are defined. You can import subprocess again with a shorter name if you like:
import subprocess as sp
sp.stuff
I don't believe there's any memory savings with 'from ... import' -- just convenience. (could be wrong)
+ 3
I'm mostly saying you can reimport subprocess; Python can handle it (and yeah, I was just saving you keystrokes).
Pipes (file descriptors 0, 1 and 2: console input, output and error) are different. To capture file descriptors from system calls, I feel like you may need to hook*
This might not be on target but seems close to the idea:
https://github.com/potatobowl/fd-progress
and then there's Python Arsenal, a grey hat toolkit. You may also want to look at Microsoft's SysInternals tools.
* Unfortunately I'm Android-only at the moment.
+ 2
Hint: Try running 'python.exe'
+ 1
Wow, sorry for the delay. I've got some connection trouble but this search looked promising:
Windows API Hooking in Python with Deviare [Google]
A 'CreateFile' example there
+ 1
cool. I had seen that one. I plan on trying it once I convert the rest of my programs to 3.6. thanks :)
0
I see your post. I'm on a phone only at the moment... trying to make edit to match 7:. just a minute...
0
your meaning so I don't have to type subprocess within the code I just type sp. I don't mind cleaning it up at some point but untill it works overall readability is key. thanks for your edits. could you try it by replacing craftware.exe with something like word processor and see if it catches when you save a file?
0
I corrected the error you spoke of. if you know of another way to do this like a .bat file I'm all ears. I am however trying to limit from using too many languages. this is a step in a much larger project. I find it easier to prototype in small one off scripts before adding it.
0
found various documentation pertaining to hooking.
https://software.intel.com/sites/landingpage/pintool/docs/71313/Pin/html/
https://github.com/jingpu/pintools/blob/master/source/tools/ManualExamples/strace.cpp
http://j00ru.vexillium.org/syscalls/nt/32/
is this the direction you were suggesting? I don't understand much of this. if you are familiar could you provide further assistance?
0
if you know of any good documentation on the kind of hook your referring to I am all ears.