What happens to -i ?
gminick at hacker.pl
Sun Feb 9 18:14:54 CET 2003
Dnia Sun, 09 Feb 2003 16:42:13 -0000, Lee Harr napisał(a):
> I am trying to determine if a script has been run with
> the -i flag.
> What happens to -i ?
That '-i' lies in the argv of python process not in argv of dashi.py
> How can I tell if -i was specified?
Here you're (this solution is /proc filesystem dependent):
import os, sys
path = "/proc/%d/cmdline" % (os.getpid())
r = open(path, "r")
cmdline = r.read()
if '-i' in cmdline: #!!! i assume you're using 2.3alpha1 ;]
print "-i is there"
print "there's no -i"
% python py.py
there's no -i
% python -i py.py
-i is there
[ ] gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/ [ ]
[ "Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej." ]
More information about the Python-list