Mounting shares with python

M

Marcpp

Hi, when i mount a share with python...

os.system ("mount -t smbfs -o username=nobody ...")

the problem is that I'll to be root.
Have a comand to send a root password...?
I've tried

os.system ("su")
os.system ("the password")

but it doesn't works.
 
D

Diez B. Roggisch

Marcpp said:
Hi, when i mount a share with python...

os.system ("mount -t smbfs -o username=nobody ...")

the problem is that I'll to be root.
Have a comand to send a root password...?
I've tried

os.system ("su")
os.system ("the password")

but it doesn't works.

You can try to use sudo

os.system ("sudo mount -t smbfs -o username=nobody ...")

It must be configured properly of course.

Diez
 
M

Michael Bentley

Hi, when i mount a share with python...

os.system ("mount -t smbfs -o username=nobody ...")

the problem is that I'll to be root.
Have a comand to send a root password...?
I've tried

os.system ("su")
os.system ("the password")

but it doesn't works.

Each call to os.system() spawns a new shell, so that approach
wouldn't work. If you have sudo configured such that you don't need
a password, you can use os.system ("sudo mount -t smbfs -o
username=nobody ..."). Otherwise (if you must use a password for
sudo -- or if you don't have sudo), you can use popen2 module <http://
docs.python.org/lib/module-popen2.html> to spawn a process you can
interact with.

-michael
 
C

Carl J. Van Arsdall

Marcpp said:
Hi, when i mount a share with python...

os.system ("mount -t smbfs -o username=nobody ...")

the problem is that I'll to be root.
Have a comand to send a root password...?
I've tried

os.system ("su")
os.system ("the password")

but it doesn't works.
I do a lot of that type of stuff. Just setup sudo access for that user
and have it state no password.

I also do that stuff on remote machines, similarly, setup ssh such that
you don't need to use a password. It will work :)

-c

--

Carl J. Van Arsdall
(e-mail address removed)
Build and Release
MontaVista Software
 
B

Bjoern Schliessmann

Marcpp said:
Hi, when i mount a share with python...

os.system ("mount -t smbfs -o username=nobody ...")

the problem is that I'll to be root.

Consider modifying /etc/fstab.
Have a comand to send a root password...?
I've tried

os.system ("su")
os.system ("the password")

but it doesn't works.

Be advised that storing a root password as clear text can be a huge
security risk. Use sudo.

Regards,


Björn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top