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
1 vote
0 answers
15 views

How to run a cron job using launchd? [duplicate]

I have a simple cron job: MAILTO=“” 0 9 * * * /path/to/job My issue with this job being that it won’t run if my Mac isn’t up and running (sleep mode). I read launchd/launchctl may be what I’m looking ...
user129393192's user avatar
0 votes
0 answers
26 views

Prevent double clicked SH script from being entered into ZSH history on Mac

I've got some SH scripts which I double click to run. The scripts run as intended, after having set the working directory via cd "$(dirname "$0")" at the beginning of the script, ...
ubiquibacon's user avatar
0 votes
0 answers
9 views

Is Apple Music (the app, not the service) for Windows scriptable? [migrated]

Apple used to support COM as API for iTunes. AFAIK, this support has been officially dropped. Now with Apple Music for Windows on the horizon, is there any information available whether, and if so how,...
hendrik's user avatar
  • 713
1 vote
1 answer
134 views

ps return pid/name of process that called script.sh

I am running an app that calls script.sh and I would like to retrieve the invoking app's PID or name within that same script.sh. Ultimately, in my script.sh, I am trying to determine whether the app ...
John's user avatar
  • 873
1 vote
0 answers
26 views

Is there a simple way to start a bash script at login or startup WITHOUT revealing the terminal? [duplicate]

I know similar questions have been asked on forums, but due to the constraints of my script, the other solutions are either too complicated or do not work. Please forgive my lack of knowledge in the ...
hidden_machine's user avatar
1 vote
2 answers
93 views

Escape control characters in bash script

I need a solution to escape control characters from a string. What I need is to turn this: %f4^rH13#b$rHN into this: %f4\^rH13\#b\$rHN I found a solution working with GNU sed on stackoverflow, which ...
Nils's user avatar
  • 141
0 votes
0 answers
41 views

macOS - run bash script when specific URL is clicked

Is it possible to write an AppleScript or macOS service/daemon to detect when a URL is clicked (which would launch the browser) and run a bash script as well/instead? Use case: detect when github.com ...
Tom Oakley's user avatar
0 votes
0 answers
17 views

Using SummarizeService from Shortcuts

I’d like to build a Shortcut that runs the MacOS Summarize service on some text input. It looks like there’s no built-in support for summarizing text in Shortcut so I’m curious if I can make a ...
Edward Ocampo-Gooding's user avatar
0 votes
0 answers
72 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 ...
Ento's user avatar
  • 1
0 votes
2 answers
79 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=...
Simon L's user avatar
1 vote
1 answer
86 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 ...
bittscoterie's user avatar
1 vote
1 answer
85 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, ...
a06e's user avatar
  • 233
2 votes
1 answer
101 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 ...
Andrew Lazarus's user avatar
1 vote
0 answers
64 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&...
Robin Métral's user avatar
0 votes
0 answers
34 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 ...
Umbrella_Programmer's user avatar
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 ...
Suraj Mandal's user avatar
1 vote
1 answer
131 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 ...
Denise's user avatar
  • 13
0 votes
0 answers
28 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
55 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 ...
epodegrid's user avatar
0 votes
0 answers
19 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....
kamran1124's user avatar
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 ...
jamesxdigital's user avatar
0 votes
0 answers
141 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.
Manikandan N's user avatar
0 votes
1 answer
38 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 ...
Barzi2001's user avatar
  • 111
0 votes
0 answers
91 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 ...
Dmitry Kabanov's user avatar
0 votes
2 answers
39 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&...
ganidran's user avatar
2 votes
2 answers
350 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 ...
luckman212's user avatar
  • 2,228
0 votes
1 answer
396 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/...
ali srn's user avatar
  • 101
1 vote
1 answer
285 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 ...
Caine0027's user avatar
3 votes
1 answer
1k 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 ...
Jay Cummins's user avatar
1 vote
2 answers
103 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 ...
godawgs's user avatar
  • 11
0 votes
0 answers
43 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.
Richard Domingo's user avatar
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 ...
Aussie Cryptocurrency's user avatar
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 ...
Franklin Gedler's user avatar
0 votes
0 answers
33 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): ...
Alex K's user avatar
  • 1
0 votes
0 answers
86 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....
zequila's user avatar
0 votes
0 answers
172 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 ...
Er Fex's user avatar
  • 1
1 vote
2 answers
241 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: ...
Ryo's user avatar
  • 121
3 votes
0 answers
283 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 ...
abdusco's user avatar
  • 131
0 votes
0 answers
312 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 ...
DasKraut's user avatar
1 vote
0 answers
107 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 ...
mivk's user avatar
  • 965
0 votes
0 answers
32 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
cody's user avatar
  • 1
1 vote
2 answers
453 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 ...
itoldusoandso's user avatar
1 vote
3 answers
380 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 ...
ChrisC's user avatar
  • 205
1 vote
1 answer
115 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 ...
fegax's user avatar
  • 121
4 votes
1 answer
581 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 ...
mellow-yellow's user avatar
0 votes
0 answers
55 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 ...
user1950278's user avatar
1 vote
0 answers
154 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?
Pikmin's user avatar
  • 11
0 votes
1 answer
33 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 ...
dan's user avatar
  • 11.7k
0 votes
1 answer
62 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 ...
Lucas Fray Burchardt's user avatar
0 votes
0 answers
267 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 │ │ └...
boogeyman's user avatar

1
2 3 4 5
15