Skip to main content
The 2024 Developer Survey results are live! See the results

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
74 votes
13 answers
44k 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?
ocodo's user avatar
  • 1,673
59 votes
3 answers
100k 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 ...
Nicholas Hassan's user avatar
54 votes
8 answers
56k 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 ...
sh-beta's user avatar
  • 735
49 votes
10 answers
128k 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 ...
prateeak ojha's user avatar
44 votes
8 answers
97k 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.
michelemarcon's user avatar
38 votes
6 answers
21k 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 ...
g_rmz's user avatar
  • 553
38 votes
7 answers
17k 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 ...
Jakub Roztocil's user avatar
37 votes
4 answers
33k views

Where is my crontab file?

I want to edit my crontab file to schedule a script. Where do I find it?
Casebash's user avatar
  • 4,403
36 votes
6 answers
31k 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: ...
racl101's user avatar
  • 483
32 votes
10 answers
70k 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 ...
Harry's user avatar
  • 609
31 votes
2 answers
219k 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 ...
0lesya's user avatar
  • 455
30 votes
2 answers
21k 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 ...
daviesgeek's user avatar
  • 39.1k
27 votes
5 answers
57k views

How to make a Mac OS X .app with a shell script?

I tried following a few tutorials, but I get this: How can I fix this? I added in a info.plist (I just copied and pasted another app's file, and changed around a few things.) Also, I used chmod +x ...
Flare Cat's user avatar
  • 911
26 votes
4 answers
26k 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" ...
John Shepard's user avatar
25 votes
1 answer
134k 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. I'...
Thunderforge's user avatar
  • 2,113
24 votes
3 answers
34k views

How do I write a script that opens an iTerm2 window and runs a command?

What I'm doing I'm using iTerm2 Build 3.0.15 and writing a script that opens a new window and prints "hello world" to the screen. Really, I'm interested in being to run any command but using echo "...
mbigras's user avatar
  • 1,230
24 votes
1 answer
38k 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 ...
Ameer Hamza's user avatar
24 votes
4 answers
10k 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 ...
Reid's user avatar
  • 824
23 votes
5 answers
31k 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 ...
ylluminate's user avatar
  • 5,461
22 votes
1 answer
6k 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 ...
Coyotwill's user avatar
  • 339
21 votes
8 answers
57k 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 ...
Elad Benda's user avatar
  • 1,602
21 votes
1 answer
6k views

How to get `ts` program on the mac

On linux there is a great command line program ts. It adds a timestamp to the beginning of each line of input. Here is an example (on some linux machine): root@227ee318bbc1:~# echo -e '1\n2\n3' 1 2 ...
bessarabov's user avatar
21 votes
1 answer
18k 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 ...
voices's user avatar
  • 2,239
20 votes
3 answers
3k views

What are the downsides of putting GNU coreutills first in ${PATH}?

I'm coming from Linux to macOS, and many of my scripts assume GNU versions of the utils provided in GNU coreutils. I could just put the GNU coreutils bin directory in earlier in $PATH than /bin. Is ...
Tom Hale's user avatar
  • 331
20 votes
9 answers
20k 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 ...
djb's user avatar
  • 443
16 votes
4 answers
107k 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 ...
Dmitriy's user avatar
  • 421
16 votes
1 answer
13k 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?...
D.W.'s user avatar
  • 4,047
15 votes
6 answers
11k views

Convert bash script to a compiled standalone binary executable, not text

I want to make a Bash script executable by the kernel. I have already used the chmod +x command and #!/bin/bash to make it executable and it works, but that I want to do is make it an executable ...
GKatz's user avatar
  • 199
14 votes
5 answers
132k 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 /...
rogerFernand's user avatar
14 votes
1 answer
9k 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 ...
bmike's user avatar
  • 238k
14 votes
4 answers
16k 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 ...
Haravikk's user avatar
  • 1,657
14 votes
5 answers
17k 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 ...
Nathan Greenstein's user avatar
13 votes
3 answers
55k 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: /...
Mowzer's user avatar
  • 327
13 votes
1 answer
86k views

How can I export an iMessage conversation to .txt or .pdf from Mac?

I need to export the chat history of an iMessage chat to either a text or PDF file. I realize this is a common question, but I ask it again because preferably, each message should have beside it a ...
karathrace99's user avatar
13 votes
6 answers
8k 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 ...
bloudraak's user avatar
  • 387
13 votes
2 answers
9k 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 ...
A Sz's user avatar
  • 233
13 votes
1 answer
2k 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 ...
Chauncey Garrett's user avatar
12 votes
5 answers
19k 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 ...
danieldekay's user avatar
11 votes
4 answers
8k views

Do Macs come with any programming language available from the Terminal?

I need to do a few little scripts on my Mac but I don't really want to install Xcode or Python for a full environment, just a quick command line deal. Does macOS come with anything suitable out of the ...
Mr. Boy's user avatar
  • 2,717
11 votes
6 answers
11k views

How to run script at wake?

I'm looking for a method to run a script (well, a single shell command) when my laptop wakes from sleep. This question has been asked before, but 8 years ago (for OS X Lion), and several of the ...
benwiggy's user avatar
  • 37k
11 votes
7 answers
14k views

Alternatives to command line unzip?

I've found that the command line unzip tool doesn't gracefully handle some of the files I'm unzipping: it makes a bunch of junk directories, and creates files whose resource forks aren't found. (...
Kevin Cantu's user avatar
11 votes
2 answers
2k 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 ...
ShreevatsaR's user avatar
10 votes
3 answers
3k 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 ...
SMaxTH's user avatar
  • 101
10 votes
2 answers
2k 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:...
Erics's user avatar
  • 203
10 votes
4 answers
8k 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, *...
Fake Name's user avatar
  • 5,419
10 votes
3 answers
4k views

Default Bash 3 overriding shebang /bin/bash with brew installed bash 4

Background Bash 4 installed successfully using homebrew and the additional steps required to make bash 4 your default shell. Many guides on the net with a simple google: Example Bash 4 upgrade guide ...
RST's user avatar
  • 291
9 votes
4 answers
19k 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 -...
v3nt's user avatar
  • 648
9 votes
2 answers
5k views

Updating just Safari through terminal on Big Sur

There is a new version of Safari and I'm trying to update just Safari on my machine using a terminal command. I have Big Sur 11.6.3. I've done Softwareupdate -l and I see the Safari update there. I ...
Lucy_Gucy's user avatar
  • 171
9 votes
3 answers
3k 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. ...
babelmonk's user avatar
  • 358
9 votes
1 answer
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 ...
Chealion's user avatar
  • 8,048

1
2 3 4 5
16