Get my current path using a python script as a command -
i put python script /usr/local/bin
use command in bash.
i want use bash working directory, current directory script executed.
is there way use current directory command does? e.g. convert2ogg (as python script in /usr/local/bin)
$ cd ~/music $ convert2ogg *.mp3
import os,sys print("cwd: "+os.getcwd()) print("script: "+sys.argv[0]) print(".exe: "+os.path.dirname(sys.executable)) print("script dir: "+ os.path.realpath(os.path.dirname(sys.argv[0]))) pathname, scriptname = os.path.split(sys.argv[0]) print("relative script dir: "+pathname) print("script dir: "+ os.path.abspath(pathname))
this code clear me. os.path
not solution problems ;) answer, , seems ask before. first line os.getcwd()
solved problem.
Comments
Post a Comment