Last active
August 29, 2015 14:16
-
-
Save eahrold/cbff74461bba8e8e4c0b to your computer and use it in GitHub Desktop.
Mount an AFP Share (JSSImporter test...)
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/env python | |
import urllib | |
import subprocess, os | |
''' Set these ''' | |
user = "your_username" | |
password = "your_password" | |
server = "your.server.com" | |
share_point = "CasperShare" | |
# make adjustments here to test... | |
safe_string = "~() *!.\'" | |
''' Done editing ''' | |
mount_point = "/Volumes/%s" % share_point | |
if not os.path.isfile: | |
try: | |
os.mkdir(mount_point) | |
except: | |
pass | |
upass = unicode(password.encode('utf-8')) | |
encpass = urllib.quote(upass, safe=safe_string) | |
url = "afp://%s:%s@%s/%s" % (user, encpass, server, share_point) | |
args = ['mount', '-t', 'afp', url,mount_point] | |
try: | |
subprocess.check_call(args) | |
except Exception , e: | |
os.rmdir(mount_point) | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment