On Tue, Nov 8, 2011 at 2:19 PM, MrSmile <n...@mail.de> wrote: > Hi people! > I am looking for a way to get the command line in the script. > > Let us say I am in the folder "/tmp" okay! > > now from /tmp I execute in the console this: > python /home/tamer/MyApp/MyScript.py > > in the app itself, I want to grep the path and the scriptname itself, > like: /home/tamer/MyApp is being somewhere available.
Under your example conditions: sys.argv[0] will be "/home/tamer/MyApp/MyScript.py". (A) os.getcwd() will return "/tmp". (B) The `os.path` module is also very relevant: http://docs.python.org/library/os.path.html Cheers, Chris -- http://rebertia.com (A): http://docs.python.org/library/sys.html#sys.argv (B): http://docs.python.org/library/os.html#os.getcwd -- http://mail.python.org/mailman/listinfo/python-list