I need to mount a directory \"dir\" on a network machine \"data\" using python on a linux machine
I know that I can send the command via command line:
mk
Example using the subprocess
module:
import subprocess
subprocess.Popen(["mkdir", "~/mnt/data_dir", "mount", "-t", "data:/dir/", "/mnt/data_dir"])
OR
import subprocess
subprocess.Popen("mkdir ~/mnt/data_dir mount -t data:/dir/ /mnt/data_dir", shell=True)
The second version uses the shell to execute the command. While more readable and easier to use in most situations, it should be avoided when passing user submitted arguments as those might lead to shell injection (i.e. execution of other commands than mkdir in this case).