Skip to content
Advertisement

Tag: linux

Change working directory in shell with a python script

I want to implement a userland command that will take one of its arguments (path) and change the directory to that dir. After the program completion I would like the shell to be in that directory. So I want to implement cd command, but with external program. Can it be done in a python script or I have to write

fcntl substitute on Windows

I received a Python project (which happens to be a Django project, if that matters,) that uses the fcntl module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an ImportError, because this module does not exist here. Is there any way for me

os.system() execute command under which linux shell?

I am using /bin/tcsh as my default shell. However, the tcsh style command os.system(‘setenv VAR val’) doesn’t work for me. But os.system(‘export VAR=val’) works. So my question is how can I know the os.system() run command under which shell? Answer os.system() just calls the system() system call (“man 3 system”). On most *nixes this means you get /bin/sh. Note that

Advertisement