1

I've managed to open the terminal in the right folder using AppleScript. but I can't figure out how to make it run node index.

How the line of code looks so far:

do shell script "open -a 'Terminal' ~/Competitor\\ Monitoring/Magic"

The idea is to package it as a program and run it daily through a calendar action.

1 Answer 1

2

You may have the cart before the horse here (or even two carts if you really want launchd or cron to schedule your process to run).

I would save your command to a script file and test it with your chosen shell (zsh recommended) and when it works manually, rename it to file.command and then open the file directly

open ~/Competitor\ Monitoring/Magic/run_node.command

Here is a bash example on letting the script check your directory if you don’t want to hard code them. It’s simpler to put everything in the same folder, though and then you don’t need any of the checking of path at all or passing the path to the script or command to the application after it launches.

Your script might be as simple as:

#!/usr/bin/env zsh

node index
2
  • 1
    If you want to go to extremes, the script might be as simple as #!/usr/local/bin/node index (one line only) :-) Commented May 11, 2022 at 15:15
  • I debated how much to include @nohillside that’s an excellent point. If figured learning env was useful to have in the most minimal script especially if paths are foreign Commented May 11, 2022 at 17:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.