如何更改调用python脚本的命令窗口的当前目录
我正在编写一个python脚本,它应该根据用户的输入将当前shell的目录(cd)更改为一个特定的目录。你知道吗
问题是每次这个脚本结束时,我都会回到原来的路径,没有改变。你知道吗
bash-4.2$ pwd
/home/<username>/scripts
bash-4.2$ ./enterFW.py -fw <fw>
/filer/syslog_ng/2019/<fw>/2019/01/28 #<--I print the new directory, and it should be correct
bash-4.2$ pwd
/home/<username>/scripts #<-however after the script ends, i am back again to the original path
bash-4.2$
我更改目录,使用subprocess.call(['cd', <new path>])
,或os.chdir(<new path>)
…都是相同的。你知道吗
请检查,并告知
我唯一能想到的办法就是解决问题。在那里你可以得到你的产品 当前shell中的脚本。否则一切都会在子shell中执行。你知道吗
你知道吗我的程序.py你知道吗
在linux shell中:
相关问题 更多 >
编程相关推荐