Last active
August 29, 2016 01:59
-
-
Save nitrocode/192d5667ce9da67c8eac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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