需要找到哪个程序调用了python脚本 [英] Need to find which program called the python script
问题描述
我正在使用一个构建系统(waf),它是 Python 的包装器.有一些程序(perl 脚本、exe 等)调用 python 构建系统.当我从 cmd.exe 执行构建脚本时,我需要找出调用它的程序.我的操作系统是 windows 7.我尝试在 python 模块中获取父 PID,它返回cmd"作为 PPID 和python.exe"作为 PID,所以这种方法没有帮助我找到我正在寻找的东西.
I am using a build system(waf) which is a wrapper around python. There are some programs(perl scripts,exe's etc) calling the python build system. When I execute the build scripts from cmd.exe, I need to find out the program that called it. My OS is windows 7. I tried getting the parent PID in a python module and it returns "cmd" as PPID and "python.exe" as PID, so that approach did not help me in finding what I am looking for.
我相信我应该在操作系统级别查看一些堆栈跟踪,但我无法找到如何去做.请帮助我解决我应该采取的方法或可能的代码片段.我只需要知道调用系统的脚本或程序的名称,例如 caller.perl、callload.exe
I believe I should be looking at some stacktraces on a OS level, but am not able to find how to do it. Please help me with the approach I should take or a possible code snippet. I just need to know the name of the script or program that called the system, example caller.perl, callload.exe
谢谢
推荐答案
我能够使用进程资源管理器查看被调用的进程链,并且能够通过遍历父进程来检索名称.感谢所有回答的人.
I was able to use process explorer to see the chain of processes called and was able to retrieve the name by just traversing the parent. Thanks for all who replied.
这篇关于需要找到哪个程序调用了python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!