Questions tagged [script]

A collection of commands that may be from a CLI Shell, or programming language such as AppleScript, which are executed in order with limited iteration, usually as a way of automating actions or events.

Filter by
Sorted by
Tagged with
52
votes
10answers
28k views

How can I change a file or folder icon using the Terminal

How can I change or set the icon for a file or folder, in the terminal, do I need to use a scripting language?
48
votes
6answers
40k views

Possible to run scripts on sleep and wake?

MacBook Pro 2010 running OS X Lion. Is it possible to run scripts on sleep and wake events? My specific application is that I've got Dropbox-synced Truecrypt volumes that I regularly use on both my ...
30
votes
7answers
78k views

Way to logout a user from the command line in OS X 10.9

I want to logout my Mac OS X from the command line. My OS X version is 10.9. I tried command pkill -KILL -u uid, but this command didn't work out. Is there a command that can be used to log out a user ...
28
votes
7answers
61k views

How to send an email from command line?

How to send an email from command line or script? I want to be able to run the script programmatically by passing the receiver and the message.
26
votes
4answers
20k views

Where is my crontab file?

I want to edit my crontab file to schedule a script. Where do I find it?
24
votes
6answers
12k views

Toggle “Use all F1, F2 as standard keys” via script

I toggle the "Use all F1, F2 as standard keys" setting very often and would like to automate it via a script (or a keyboard shortcut). Is it possible? I've tried to Google the right arguments for ...
23
votes
9answers
43k views

Create a new (.txt) File in Finder - Keyboard Shortcut

I wanted to know if there is way to set keyboard shortcuts to make new files in Finder. For example, by default, you can create a new folder using CMD+Shift+N. Is there a keyboard shortcut to create a ...
22
votes
1answer
77k views

Full privileges on .command file, but it says I don't have appropriate privileges

I have a command that I regularly need to run in the Terminal (for application code signing). Normally I launch the Terminal, press the up arrow until I reach the command I want, and then hit enter. ...
22
votes
4answers
9k views

Concisely starting Mac OS apps from the command line

I do a fair amount of work in the command line, and I find myself defining a lot of aliases of the form: alias skim='/Applications/Skim.app/Contents/MacOS/Skim' Is there a way to add magic such that ...
21
votes
2answers
16k views

What is the difference between .command, .tool, and .sh file extensions?

I saw a couple of questions about executing command line scripts? I saw that the .command and .tool extensions were mentioned. I have always used .sh. What is the difference between these different ...
20
votes
4answers
19k views

Mojave: disable or control the “[SOME_APP_NAME] wants access to control [ANOTHER_APP_NAME (often Finder)] …”?

A new security feature in Mojave revolves around a system dialogue that prompts you to grant access to apps that want to control other apps, such as Finder (I'm finding frequently happening with some ...
18
votes
4answers
17k views

My Automator Workflow fails because it fails to find the git command within the 'Run Shell Script' command? Need help

I have an Automator workflow and one of the actions is to clone a repository. Here's the code for the 'Run Shell Script' action. The command is run within the Bash shell /bin/bash if that matters: ...
18
votes
2answers
81k views

How to create a universal (script) file for a Mac, based on several Terminal commands

I have several Terminal commands I use for troubleshooting purposes, by typing them in one by one into the terminal window. These commands require the user's password to be entered. I'm looking for ...
18
votes
7answers
41k views

How to persistently define aliases in Terminal

I want to add aliases to my environment so that they are available in all Terminal instances. I got this answer: Yes, you can put it in your .bashrc, .bash_profile or .profile. On some systems the ...
17
votes
2answers
31k views

Do Terminal processes stop if Mac sleeps?

I'm running some Python machine learning programs through Terminal that take hours at a time to finish. If I leave my computer unattended it hibernates - the screen goes off and I have to type in my ...
15
votes
5answers
13k views

Is there a Mac OSX equivalent of zenity?

I'm porting some simple X windows/bash scripts to Mac OSX, but I cannot find a build of Zenity (a Gnome app for basic GUI dialogs) for OSX. Is there some other command line driven dialog utility I can ...
15
votes
4answers
88k views

How do I execute a bash script that requires root privileges?

I have this script lines from my ISP: sudo bash echo "plugin L2TP.ppp">>/etc/ppp/options echo "l2tpnoipsec">>/etc/ppp/options It works if I paste line by line into Terminal. I want to ...
14
votes
3answers
10k views

osascript is not allowed assistive access. (-1728)

Script: #!/usr/bin/osascript tell application "System Preferences" activate set current pane to pane "com.apple.preferences.users" delay 2 tell application "System Events" ...
13
votes
1answer
19k views

Passing arguments to 'Run Shell Script' in Automator

I want to make an Automator workflow to run a shell command. For example, I want to receive text input from the user and treat that input as a shell command instead of text. I have tried passing ...
13
votes
5answers
14k views

Make a script/app run on logout

We all know that Mac OS X has the very useful Login Items functionality which lets you, among other things, set up apps/scripts to run when you log in. I'm looking for a way to setup a list of ...
12
votes
6answers
7k views

Getting notified when someone logs into a server using SSH or Remote Desktop

I have a mac mini server running OS X Lion Server 10.7.3. It pretty much runs unattended without problems. However, the server is under constant "attack" according to the logs. The firewall and ...
12
votes
1answer
867 views

Replace password prompt with Touch ID to read Keychain password

I'm using the following command to fetch a password from the Keychain in a shell script: security find-generic-password -w -s "MyServiceName" It works, but it's showing a popup window asking me for ...
11
votes
1answer
5k views

Is there a script I can use to download the Mojave installer without being signed in to the App Store?

Is there a way to script and download the Mojave installer without signing in to the App Store? Something other than opening or clicking a url that points to the installer on the Mac App Store would ...
11
votes
4answers
15k views

Are there Greasemonkey scripts for Safari?

There's the wonderful Greasemonkey to run user-defined JavaScript on web pages. Is there such a thing as Greasemonkey for Safari? Or would one instead write a Safari Extension to customize behavior ...
10
votes
3answers
2k views

I want to power off multiple Macs everyday at 23:30 (11:30 pm)?

I have this problem in my office that multiple Macs always run 24/7 and my boss said that I need to make it stop. Now I don't have much experience with Macs, I'm more the Windows type. I have one ...
10
votes
4answers
102k views

How Do I Use 'cp' to Overwrite Files?

Using a shell script or Terminal, how do I overwrite files that may or may not be present. I looked at man page for cp, it said use the -f argument to force overwrite. But, it does nothing. $ cp -f /...
10
votes
2answers
5k views

Auto-updating Homebrew

i'm currently using the Homebrew package manager and my question is: is possibile to write a bash's script in order to execute brew update and eventually brew upgrade whenever opening a shell for the ...
10
votes
2answers
799 views

How to md5 a list of filepaths contained in a file?

I have a folder containing many folders containing many files. Thousands. I can do find . -type f > ./FILE-LISTING.TXT to create a file containing many thousands of file paths that looks like this:...
10
votes
1answer
8k views

Send notification from command line [duplicate]

On Mac OS X, some applications will display a notification that appears briefly in the upper-right corner (e.g., when I receive email). Is there a way to generate a notification from the command-line?...
10
votes
1answer
6k views

Is there a `watch` command native to Darwin/OS X?

I have a script that I'm trying to port from Linux to Darwin/OS X. The Linux version currently depends on the watch command, which doesn't appear to be installed on Darwin/OS X by default. What's the ...
10
votes
4answers
12k views

Run Script on Logout Without Use of Logout Hook

I've been looking into running a few cleanup commands when a user logs out, however the old logout hook feature, although still functioning, has been deprecated for some time now so may not be with us ...
9
votes
3answers
2k views

Enable/disable Time Machine depending on network connection type

I've not got a great Wi-Fi setup here at home and it sometimes results in failed Time Machine backups. Is there a way of specifying that Time Machine only backs up under certain circumstances - i.e. ...
9
votes
2answers
3k views

|OSX 10.10.5] Script execution stops when screen locked?

I was running a script that takes ages in Terminal. I wanted to run it unsupervised while I was working away from my MacBook, so I chose from the menu (top right) username > Login Window..., which is ...
9
votes
1answer
11k views

How do I modify Word 2011 for Mac so I can see tracked changes inline and notes simultaneously?

Background: In Word 2011 for the Mac, it's possible to view tracked changes inline -- that is, see the changes made on the screen within the text itself, as opposed seeing them in a balloon off to ...
9
votes
1answer
914 views

What are the differences between Applescripts saved as *.scpt and *.applescript?

It seems to me that those scripts that are saved as *.applescript are always meant to be the raw, uncompiled text while those that are saved as *.scpt can be either the raw text or the compiled ...
8
votes
4answers
27k views

How do I create an AppleScript that will quit an application at a specific time and then put the computer to sleep?

I've been toying around with AppleScript and Automator to get this thing to work, but I just can't seem wrap my head around it. If anyone could show me an example or give me some tips on how I can set ...
8
votes
4answers
13k views

os x terminal -remove files older than x days

trying to create a scripts that deletes files older than X days. It seemed straight forward enough but all files seem to be getting removed? find /Volumes/Groups/Projects/530_BFAMI/test/ -ctime +30 -...
8
votes
3answers
2k views

Lock screen with LaunchBar

I extensively use Launchbar and have almost all my daily productivity items working through it. Since I use my personal MacBook at work, I do not have use a screen saver password, however, when at ...
8
votes
4answers
6k views

Programmatically/Script-atically changing the default Open-With setting

Is there a way to change what app opens a file type programmatically/with a script? Basically, sometimes I'm working on a web site, and I want to set all web files to open with a text editor (*.php, *...
8
votes
1answer
6k views

Turn on Back To My Mac via a Script or Command Line

The VPN software I use for work (IPSecuritas) requires me to turn off Back To My Mac to start it's connection, so I frequently turn off Back To My Mac in order to use my VPN connection (the program ...
8
votes
4answers
11k views

Checking for folder/file changes using Automator?

Is there there a way to check a folder/file for changes (includes adding files, deleting files, changes in files,...). The 'Folder action' in Automator is only checking if any files are newly added.
8
votes
1answer
907 views

Get list of all fonts containing a specific character

On macOS Sierra, I would like to get a usable list of all fonts that cover (contain a glyph for) a particular Unicode character. Is there a way to do that, either via a tool, or the commandline, or ...
7
votes
5answers
6k views

OSX Bash for loop - issues with spaces in folder names?

I'm getting a bit confused on how to handle spaces in path names when returned in a for loop. Rationale: I'm cleaning up the permissions on folders and files that I copy over from Windows. Most of ...
7
votes
1answer
530 views

Change font of Terminal programmatically w/o restarting

At home I've got a nice big display that unfortunately does not have the same resolution as my retina macbook does. I'd like to use a pixel-font on the low-res screen and a nice smooth one on the ...
7
votes
2answers
2k views

What's the easiest way to automate logging into a website?

There's this website I need to access about every ten minutes. And apparently it was designed in 1993, by sadists. There is no "remember me on this computer" checkbox. And if you don't interact with ...
7
votes
3answers
9k views

How to disable individual USB ports by script?

I am looking for a script which will allow me to disable one specific USB port on my Mac mini. It would only serve a purpose if it works in real-time and didn't require a reboot. I've found scripts ...
6
votes
6answers
9k views

How to launch browser in iOS Simulator from command line?

I want to launch the browser in iOS Simulator from the Terminal with specified URL. Is there any command for it? So that I can write in a script which will take URL as argument and launch simulator ...
6
votes
3answers
27k views

How to run a shell script from an AppleScript?

I am using a Mac running OSX Yosemite v.10.10.5. When I try to run my shell script from my AppleScript, I get the following error message: Error message at AppleScript Script Editor error "sh: /...
6
votes
1answer
5k views

Mounting Samba shares under /Volumes without GUI fluff

I know I can mount Samba share using either mount or open command from the terminal shell. See this related question: How can I mount an SMB share from the command line?. I prefer using open because ...
6
votes
3answers
7k views

Opening a terminal window to a specific directory from a bash script

How can I write a bash script in Mac OS X that opens a Terminal window in a specific directory? I'd assume something like: open /Applications/Utilities/Terminal.app But that does nothing (maybe it'...