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
0 votes
0 answers
22 views

Download file from iCloud/GoogleDrive from Terminal or script

I use Ventura with iCloud and also GoogleDrive. I have some files in iCloud, not physically available on my MacBook, but I could right-click on it and click to "download now" (basically OS ...
  • 1
0 votes
2 answers
37 views

Shell script application bundle prompts for Rosetta installation

I exported the following line of AppleScript code into an macOS application via the "Script Editor": do shell script "open '/Applications/Google Chrome.app' --args --proxy-server=...
1 vote
1 answer
50 views

How to Implement a Dictionary Look Up Script on Mac and Save to History Log: Need Help with Syntax Errors

After several times of having my MacBook shutdown and losing the several tabs I had opened of the words I looked up, I've started to look for a solution. I'm currently trying to implement a script ...
1 vote
1 answer
43 views

Query whether MacBook is plugged or on battery from shell script

I am writing a shell script that I will leave running in background for some syncing tasks. I would like this script to behave differently depending on whether my MacBook is plugged to a power source, ...
  • 143
1 vote
1 answer
57 views

Script to run Apple Inbox Rules

Note: I am not asking how to create a rule which runs an Applescript. I want to go the other way around: run a script that will apply existing rules to all the messages in the inbox. That is, simulate ...
1 vote
0 answers
52 views

Automator workflow crashing silently when ran as Finder extension

I made an Automator workflow that essentially runs a shell script to optimize images. I intend to use it as a Finder.app extension, by selecting images and running the workflow as a "quick action&...
0 votes
0 answers
27 views

How do I use launchctl to hook a shell script to a login / logout event?

I have been trying to get a shell script to fire on login / logout events on a Mac, but the method I used is very old, and it does not work. I followed this StackExchange post and used the sudo ...
0 votes
0 answers
16 views

A script that opens .py types in values required

First a bit of backstory, when I do python assignments I had to manually add inventory items again and again which was painful so I wrote a shell script which would start my python program and enter ...
1 vote
1 answer
95 views

How do I point the mkdir to the Desktop using bin/zsh? I am on macOS $HOME

How do I make this create the directory on my Mac desktop rather than the home folder alone. mkdir -p "$HOME/${digits}_${date}" Right now it goes to /Users/name/ I need it to go one more ...
  • 13
0 votes
0 answers
22 views

How do I create a desktop icon for launching a script that doesn’t exit terminal

I created a desktop alias for a ruby script that launches the script with no arguments and when it opens it says exit saving session and leaves the terminal open not allowing me to input arguments. I ...
user avatar
0 votes
1 answer
47 views

Undentified shell script "open" added to open at login

Logged in into my laptop this morning, to see that a shell script "open" has been added to open at login. Its from an unidentified developer, created a month back, but just got added to ...
0 votes
0 answers
13 views

Editing Volume limit script on Mac

this is the script I use from this article https://medium.com/trabe/limiting-your-macs-volume-in-2019-f314e20408ab . It works perfectly. constructor(appName, maxVolume) { this.app = Application....
1 vote
0 answers
13 views

Mac Automator - When given a folder containing many files with the same name format, organise the folder with new sub-folders [duplicate]

So I have a folder which contains many .mp3 and .cdg files (setting up a Karaoke system 😅) All of the files follow the same naming system: Artist - Song name [Karaoke] Rather than having all of the ...
0 votes
0 answers
91 views

Create similar to .exe file for mac os [duplicate]

I need create a non reable executable script for mac os. Example. I have .exe for windows user and they cant open and see the source code. Similarly i need to create executable application for mac os.
0 votes
1 answer
35 views

How to create an app from a .command file? [duplicate]

I have a MyMacVim.command file with this content: source ~/.zshrc /Applications/MacVim.app/Contents/bin/mvim Is it possible to create an app, say MyMacVim.app, from MyMacVim.command that I can place ...
  • 111
0 votes
0 answers
60 views

Compiled Javascript for Automation (JXA) script does not show applications

I wrote a small script to sync one folder to another as a Javascript for Automation script. If I run it directly from terminal: $ osascript -l JavaScript myscript.js then it works as supposed - the ...
0 votes
2 answers
37 views

If/then statement comparing OSX app to specific version

Having trouble making a simple script that outputs if the version matches or if it doesn't. Using VS Code as an example. I input this in terminal: osascript -e 'version of app "Visual Studio Code&...
2 votes
2 answers
220 views

How can I determine the volume name of the default boot disk from Terminal?

I have some shell scripts that need to access paths under /Volumes/ e.g. /Volumes/MyDisk/tmp/foo.json. Right now the scripts have hardcoded volume names. I would like to make them portable so they run ...
  • 2,086
0 votes
1 answer
248 views

How to stop dotnet run command?

I have written a script to build and run my dotnet project but it seems I am not able to stop it. The code I wrote is below. do shell script "eval $(/usr/libexec/path_helper -s) cd /Users/...
  • 101
1 vote
1 answer
220 views

Reset Mac Login Password Using Shell Script Without putting Old/Existing Password (forgotten password)

I'd like to script password changes where I don't know the existing admin password and tried unsuccessfully: dscl . -passwd /Users/[user short name] [password] When I hit enter, it still asks the ...
3 votes
1 answer
783 views

How to run multi-line curl statement from a script in terminal?

I am attempting to run a curl statement that I copied from Chrome DevTools. The statement has a bunch of Header parameters. If I paste this into a Terminal window, it works great. If I drop this into ...
1 vote
2 answers
97 views

Issue running command in cronjob but works as a regular command [duplicate]

I'm trying to run a yt-dlp command inside a cronjob but am having trouble. The command runs fine when run as a regular terminal command but inside a cronjob it fails. I've included an image of the ...
  • 11
0 votes
0 answers
72 views

'While true' loop suddenly stops

So I want to run a one liner while loop that prints the size of a file whilst I'm coping it, so I tried this: while true; size1=$(ls -hl /Volumes/WD\ Elements/redundancy/20221117_0148_backup.tar.gz | ...
0 votes
0 answers
40 views

How can you launch emoji viewer via osascript?

I'd like to add a mapping in neovide. And one way to do it by by remapping <C-D-Space> and run the script that opens the emoji viewer programatically.
2 votes
1 answer
91 views

Using text document of whitespace containing filenames to batchcopy between directories in Terminal [closed]

I am using terminal in MacOS Ventura. I want to have a textfile of files which I will copy using the terminal. This won't work when spaces are in the filenames. A=~/Documents/test1 B=~/Documents/test2 ...
1 vote
0 answers
21 views

run second script in a new terminal window [duplicate]

I have two scripts; script_1 and script_2, the latter must receive 2 parameters. Before finishing script_1 I want it to call and execute script_2 in a new terminal window and pass it the 2 ...
0 votes
0 answers
30 views

Automator SCRIPT help!: Select name of file, find file with containing name, then copy this item in another folder

I have 3 folders: JPG folder; contains my modified JPG files, filename example: AKK05140.jpg RAW folder: contains my RAW files, filename example: AKK05140.RAW DESTINATION folder (Edited RAW files): ...
  • 1
0 votes
0 answers
68 views

How can I execute a shell command just before login screen?

I apologize if the question has already been asked. macOS Monterey. For a few days now, the blinking cursor of the login screen is not blinking anymore, so I can't type any character and I can't logon....
0 votes
0 answers
141 views

Problem with Apple Shortcuts with operation not permitted on script

I'm new to macOS and Linux-based systems (and I'm also not an IT guy, just having fun learning basic stuff from many fields), and I wanted to make a shortcut with the Apple Shortcut application to ...
  • 1
1 vote
2 answers
167 views

macOS: Double click on a file and display the output from a CLI command on the file?

There is a file type called "netCDF". My goal is to be able to double click on a netCDF file on Finder and see the text output from a CLI command to which the filename is given. Specifics: ...
  • 121
3 votes
0 answers
200 views

Force reset system preferences cache

I'm trying to enable/disable time announcement feature that's present in Dock & Menu Bar > Clock > Announce the time with a shell script. When I read the plist file, I can see that it's set ...
  • 131
0 votes
0 answers
269 views

AppleScript: How to do shell script with admin privileges that only asks for password on first run/never?

I'm trying to write an AppleScript that will update the schedule boot/wake time of computer to be a hour from the time the script is run. My script below works, but every time I run it, I'm asked for ...
1 vote
0 answers
88 views

Cannot run shell script from mounted network share: unidentified developer

We have a few shared shell scripts on our file server, and would like them to run in Terminal when double-clicked in the Finder. The share is mounted, and the scripts do run when called by their full ...
  • 925
0 votes
0 answers
30 views

Mac software update app automatically open if update are already downloaded and install and require user

Script to Lauch Mac software update app automatically. eq if we have monterey12.3 and on softwareupdate.plist shows availble as 12.4 then open mac software update app
  • 1
1 vote
2 answers
305 views

Script to restart application

I need to restart an application once a day because it has memory leak and it ends up consuming several Gig of memory after a few days. Poor programming perhaps, but the developer wasn't able to ...
1 vote
3 answers
297 views

xargs: Operation not permitted when calling bash script from fswatch event

I'm trying to watch a certain folder and run a script if there is a change to the folder. For this, I'm using below fswatch command (OS is Monterey [12.0.1]): fswatch -o ~/Desktop/iosBuildZips | xargs ...
  • 205
1 vote
1 answer
89 views

How to rotate between multiple app windows using Hammerspoon?

My current code for switching to a desired app is this: hs.hotkey.bindSpec( { hyper , "k"}, function() hs.application.launchOrFocus("Visual Studio Code") end ) But I have ...
  • 121
4 votes
1 answer
531 views

On Mac, how can I move the mouse to the current caret / cursor location?

Is it possible to use AppleScript, cliclick, or a similar CLI tool to move the mouse pointer to the current location of the blinking cursor? For example, imagine the cursor is blinking at the position ...
0 votes
0 answers
54 views

Script executed when application Bluestacks is deleted from Trash

I just noticed something interesting when uninstalling Bluestacks on MacOS Monterey. I dragged the app to the trash and when I clicked empty trash, there was a prompt to allow to run a sh script. I ...
1 vote
0 answers
131 views

How do you make a .command file autostart on system bootup?

I'm on macOS Monterey 12.4. How do you make a .command file autostart on system bootup?
  • 11
0 votes
1 answer
28 views

How to get the ${DISPLAY} outside of the X environment

I would like to make a shell script and an Applescript script to fire an X environment command when this environment is active ( through XQuartz for example ). But not just upon starting the X ...
  • 11.6k
0 votes
1 answer
58 views

Change Display Scaling mode from 'Default' to 'More Space' in terminal/script

I find myself switching between macOS scaling modes often, depending on what I'm doing. Some tasks require me to use the 'More Space' option, while I prefer regular browsing and use in the Default ...
0 votes
0 answers
229 views

Automator: move files to a dynamically created folder name from subfolder

I'm trying to move downloaded files to a new folder(Get name from subfolder files). Example: Parent Folder ├── 160x600-SubFolder1.1 │ ├── AnotherSubFolderEN-Test display_a98765bcd0e12345fg │ │ └...
1 vote
1 answer
29 views

need to turn separate zsh script into a function inside a master script

I'm trying to turn 6 scripts into one script, so that instead of the enduser needing to download 6 scripts, do chmod +x mess to them etc, and then run the master script, they'd only need one script ...
  • 1,150
0 votes
0 answers
122 views

Admin account sudo code asking for password in Applescript

I'm trying to create an Applescript that COMPLETELY removes the user from having to set up an admin account AND with full access to the disk (on macbooks/macbook pros). The newly created admin account ...
0 votes
1 answer
325 views

Shell command no longer working

I'm on a M1 MacBook Pro running macOS 12.3.1. I've had some AppleScripts that perform a shell script run happily for many years. For some unknown reason these have just stopped working today - nothing ...
0 votes
0 answers
474 views

Installer is getting failed while running post install script

The installer is getting failed while running the post-install script with error: *** Couldn't posix_spawn: error 2 We are importing the certificate in the post-install script for validation. ...
0 votes
0 answers
80 views

Need to automate changes to my Display settings

As a former engineer, I know that if I find myself doing the same thing over and over, I should be able to automate that process. So here goes: Due to things beyond my control, every time I log into ...
0 votes
0 answers
134 views

Shell Script to check password has been set to Immediately and what the screen saver time is set to

I need to create a script for checking a security posture of a machine using OPSWAT MetaAccess. They have a built-in check, however, according to them, they aren't able to check since macOS 10.13+. ...
1 vote
1 answer
723 views

How to remotely & automatically switch a Mac's audio output device

I have a Mac (running Catalina) dedicated as a media server, running Plex and Spotify. I'd like to be able, from my Mac laptop, to simply click something and switch the remote Mac's audio output ...
  • 1,110

1
2 3 4 5
15