python - How to get the caller script name -


i'm using python 2.7.6 , have 2 scripts:

outer.py

import sys import os  print "outer file launching..." os.system('inner.py') 

calling inner.py:

import sys import os  print "[caller goes here]" 

i want second script (inner.py) print name of caller script (outer.py). can't pass inner.py parameter name of first script because have tons of called/caller scripts , can't refactor code.

any idea?

thanks, gianluca

one idea use psutil.

#!env/bin/python import psutil  me = psutil.process() parent = psutil.process(me.ppid()) grandparent = psutil.process(parent.ppid()) print grandparent.cmdline() 

this ofcourse dependant of how start outer.py. solution os independant.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -