Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nitrocode/192d5667ce9da67c8eac to your computer and use it in GitHub Desktop.
Save nitrocode/192d5667ce9da67c8eac to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# addmount.py
#
# This will add a shared drive using a given password. Only requirement is pexpect which can be downloaded using apt-get or pip
#
# - password contains $ and ! marks that need to be escaped
# - had issues putting these in the -o "password=" param and had issues with the cred file
import pexpect
password = "$wirleysaysneverquit!!!"
cmd = "sudo mount -t cifs -o username=myusername,domain=CORPORATE,rw,hard,nosetuids,noperm,sec=ntlm //mylong.evenlonger.shareddrivecompany.com/some/folder /mnt/folder -v"
p = pexpect.spawn(cmd)
p.expect(": ")
print(p.before + p.after + password)
p.sendline(password)
p.expect("\r\n")
output = p.read()
p.close()
list_output = output.split("\r\n")
for line in list_output:
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment