Mounting shares with python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcpp

    #1

    Mounting shares with python

    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.

  • Diez B. Roggisch

    #2
    Re: Mounting shares with python

    Marcpp wrote:
    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

    Comment

    • Michael Bentley

      #3
      Re: Mounting shares with python


      On Jan 26, 2007, at 6:40 AM, Marcpp wrote:
      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.htmlto spawn a process you can
      interact with.

      -michael

      Comment

      • Carl J. Van Arsdall

        #4
        Re: Mounting shares with python

        Marcpp wrote:
        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
        cvanarsdall@mvi sta.com
        Build and Release
        MontaVista Software

        Comment

        • Bjoern Schliessmann

          #5
          Re: Mounting shares with python

          Marcpp wrote:
          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

          --
          BOFH excuse #9:

          doppler effect

          Comment

          • half.italian@gmail.com

            #6
            Re: Mounting shares with python

            On Jan 26, 10:27 am, Bjoern Schliessmann <usenet-
            mail-0306.20.chr0n.. .@spamgourmet.c omwrote:
            Marcpp wrote:
            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
            >
            --
            BOFH excuse #9:
            >
            doppler effect
            I use pexpect. http://pexpect.sourceforge.net/

            ~Sean

            Comment

            Working...