Home > Software engineering >  Python SMB connect automatically
Python SMB connect automatically

Time:08-30

I have function for connect to Smb drive:

SMB_CONN = 'smb://192.168.10.105/Shares'
subprocess.Popen(f'open {SMB_CONN}'.split(' '))

But this code calls popup window with saved login, password & connect button.

If I create alias to any Smb folder in MacOs and click to it, Mac connect to Smb drive silently. How to repeat this functionality in python3?

I assume its possible with subprocess & AppleScript.

Update:

smbpath = 'smb://192.168.10.105/Shares'
os.system(f"osascript -e 'mount volume \"{smbpath}\"'")

working.

CodePudding user response:

smbpath = 'smb://192.168.10.105/Shares'
os.system(f"osascript -e 'mount volume \"{smbpath}\"'")

working.

  • Related