how to mount from python 2.6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amruta21
    New Member
    • Aug 2011
    • 1

    how to mount from python 2.6

    HHello,
    I am using python 2.6 on unix platform. I need to mount window drive from python. For that i done following code. But it does not get mounted.
    Code is Here..........
    Code:
    import pexpect
    cmd2="sudo mount -t cifs //<ip address>/FinalWork  /mnt/win"
    child = pexpect.spawn(cmd2)
    i = child.expect([' password .* ', pexpect.EOF, pexpect.TIMEOUT])
    if i == 0:
       print "******************sending pwd"
       child.sendline(pwd) #Here pwd is password for sudo
       print "+++++++++++given password : " + pwd
    elif i == 1:
       print "--------------EOF"
    elif i == 2:
       print "%%%%%%%%%%%%%%TIMEOUT"
    
    print "^^^^^^^^^^^^^^after pwd affair"
    child.close()
    Please let me know where i gone wrong.
    It's very urgent.
    Thanks in advance.
    Last edited by bvdet; Aug 30 '11, 02:48 PM. Reason: Add code tags
Working...