在 Mac 上使用 bash 脚本连接到网络共享?

发布于 2024-07-26 19:32:46 字数 113 浏览 7 评论 0原文

我在工作中使用 Mac,希望在启动计算机时安装一些网络共享。 我可以使用 bash 脚本(或类似脚本)来连接和挂载这些共享吗? 共享来自 Windows 和 Mac 服务器,我们通常使用 IP 地址进行连接。

I'm using a Mac at work and would like some network shares mounting when i start the computer. Can i use a bash script (or similar) to connect and mount these shares? The shares are from both Windows and Mac servers and we usually connect using IP addresses.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑忘罢 2024-08-02 19:32:46

您可以查看 mount_smbfs,假设您的网络共享是 smbfs/cifs。

mount_smbfs [-N] [-o options] [-d mode] [-f mode] [-h] //[domain;][user[:password]@]server[/share] path

我不太熟悉 OSX 启动过程,但您可以在 /Library/StartupItems 或 /System/Library/StartupItems 中将 shell 脚本创建为程序/文件夹,

osxbook.com

/etc/rc 终于启动了
/sbin/SystemStarter 处理启动
来自以下地点的物品
/系统/库/StartupItems 和
/库/启动项。 启动项
是一个程序,通常是 shell 脚本,
其名称与文件夹名称匹配。
该文件夹包含属性列表
包含键值对的文件,例如
作为描述、提供、要求、
OrderPreference、开始/停止消息
等等。您可以运行 SystemStarter -n -D
以 root 身份打印程序
调试和依赖信息
(没有实际运行任何东西)。

You could check out mount_smbfs, assuming that your network shares are smbfs/cifs.

mount_smbfs [-N] [-o options] [-d mode] [-f mode] [-h] //[domain;][user[:password]@]server[/share] path

I'm not intimately familiar with the OSX startup process, but it's possible you can create your shell-script as a program/folder in /Library/StartupItems or /System/Library/StartupItems

As mentioned on osxbook.com

/etc/rc finally launches
/sbin/SystemStarter to handle startup
items from locations such as
/System/Library/StartupItems and
/Library/StartupItems. A StartupItem
is a program, usually a shell script,
whose name matches the folder name.
The folder contains a property list
file containing key-value pairs such
as Description, Provides, Requires,
OrderPreference, start/stop messages
etc. You can run SystemStarter -n -D
as root to have the program print
debugging and dependency information
(without actually running anything).

有木有妳兜一样 2024-08-02 19:32:46

您可以通过 Apple 脚本执行此操作,只需将其添加到用户启动项,或者通过 Automator 执行此操作,然后再次添加到启动项(系统首选项 -> 用户 -> 启动项),如果您愿意,可以如果您更熟悉 Bash,也可以从 AppleScript 调用 bash 脚本,但无论如何安装共享都是一项简单的任务。
如果您想通过按键安装它们,请查看 FastScript,它可以让您将 AppleScript 操作配置为快捷方式。

You can either do this via a Apple Script which you simple add to the User Startup Items, or do it via Automator and again add to Startup Items (System Prefs -> Users -> Startup Items), If you want to you can also just call a bash script from an AppleScript if you are more familier with Bash, but mounting shares is an easy task anyway.
If you maybe like to mount them with a Keystroke, check out FastScript which lets you configure AppleScript Actions as Shortcuts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文