Reputation: 21
I am trying to mount to a CIFS share with space in my linux machine using python like below:
from subprocess import call
t = mount -t cifs -o username=kalair2 "//10.32.135.87/root/Singapore Lab/SYMM" /mnt/share
print t
if os.path.exists("/mnt/share"):
print "/mnt/share path already exists"
else:
call("mkdir /mnt/share")
call("chmod 777 /mnt/share")
print "mnt/share has been created"
call(t)
But ended up in the error... Traceback (most recent call last): File "mounttest.py", line 12, in call(t) File "/usr/lib64/python2.6/subprocess.py", line 478, in call p = Popen(*popenargs, **kwargs) File "/usr/lib64/python2.6/subprocess.py", line 642, in init errread, errwrite) File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child raise child_exception OS Error: [Err no 2] No such file or directory
It works if i execute this mount command in shell with space. Can anyone help me with this?
Upvotes: 2
Views: 4738
Reputation: 164
call
should be called with an array of arguments - not a single string for the command with the arguments, as documented here: https://docs.python.org/2/library/subprocess.html
Your command should look like this:
call(["mkdir", "/mnt/share"])
Upvotes: 0
Reputation: 113
Try escaping your space:
"//10.32.135.87/root/Singapore\ Lab/SYMM"
Upvotes: 0