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
Tag: linux
Python: get default gateway for a local interface/ip address in linux
On Linux, how can I find the default gateway for a local ip address/interface using python? I saw the question “How to get internal IP, external IP and default gateway for UPnP”, but the accepted solution only shows how to get the local IP address for a network interface on windows. Thanks. Answer For those people who don’t want an
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