简体   繁体   English

Python SMB 自动连接

[英]Python SMB connect automatically

I have function for connect to Smb drive:我有 function 用于连接到 Smb 驱动器:

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.但是此代码调用弹出窗口 window 并保存登录名、密码和连接按钮。

If I create alias to any Smb folder in MacOs and click to it, Mac connect to Smb drive silently.如果我在 MacOs 中为任何 Smb 文件夹创建别名并单击它,Mac 会静默连接到 Smb 驱动器。 How to repeat this functionality in python3?如何在 python3 中重复这个功能?

I assume its possible with subprocess & AppleScript.我假设它可能与子进程和 AppleScript 一起使用。

Update:更新:

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

working.在职的。

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

working.在职的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM