登录mac时运行脚本 [英] Running script upon login mac
问题描述
我想知道是否有人能够帮助我在我的计算机上登录帐户时运行 .sh 文件.我运行的是 Mac OS X 10.6.7.
I am wondering if anyone is able to help me out with getting a .sh file to run when I log in to my account on my computer. I am running Mac OS X 10.6.7.
我有一个文件Example.sh";当我登录到我的计算机时我想运行.我已经登录后运行它没有问题,但我希望它自动运行.
I have a file "Example.sh" that I want to run when I log onto my computer. I do not have a problem running it when I am already logged in, but I want this to run automatically.
推荐答案
按照这个:
- 启动
Automator.app
- 选择
应用程序
- 点击工具栏中的
Show library
(如果隐藏) - 添加
运行shell脚本
(来自Actions/Utilities
) - 复制&将您的脚本粘贴到窗口中
- 测试一下
保存在某个地方(例如,您可以在 HOME 中创建一个
Applications
文件夹,您将获得一个your_name.app
)
- start
Automator.app
- select
Application
- click
Show library
in the toolbar (if hidden) - add
Run shell script
(from theActions/Utilities
) - copy & paste your script into the window
- test it
save somewhere (for example you can make an
Applications
folder in your HOME, you will get anyour_name.app
)
去System Preferences
-> Accounts
-> Login items
我最近因这个答案获得了好答案"徽章.虽然我的解决方案简单且有效,但 @trisweb 的回答,除非你想要互动.
使用自动化解决方案,您可以执行以下操作:
With automator solution you can do things like next:
因此,要求运行脚本或退出应用程序、询问密码、在登录时运行其他自动化工作流程、在登录时有条件地运行应用程序等等......
so, asking to run a script or quit the app, asking passwords, running other automator workflows at login time, conditionally run applications at login time and so on...
这篇关于登录mac时运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!