Running NPM Command on Mac via Shortcuts

Hi,

I’m looking to find a way of running a terminal command via shortcuts.

How is best to achieve this and run via shortcuts. I’m imagining I need to put the command into a script and execute via SSH in shortcuts. Any guidance would be appreciated.

For info it’s just a single line from the following:

Thanks in advance for any assistance.

Certainly the simplest way if you want to automate from Shortcuts. Just specify the command in the Run Script Over SSH action. One and done.

Is there something specific beyond that you are having an issue with when implementing?

I would copy (and/or adapt) the contents of this repo into scriptable and follow the examples for setting what ever interactions you were looking for. You could then either call the scriptable script directly or through shortcuts

Thanks for the replies.

@sylumer I had specified the command in a simple SSH command in shortcuts but nothing happens.

I’ll attempt the scriptable route as that seems the most native option to run it directly from any iOS device. ay be a little tricky for me but keen to learn.

Did you check the output? I would assume there should be something returned.

Is the utility in your path when you connect for example as you don’t look to be changing directory?

You could also pipe it into a file to log when run if you wanted a running copy of the output it is producing.

Yep, I have several shortcuts that are simply one run command over ssh pointing at my server.

As do I. I tend to write and store my scripts on the servers, and then run the scripts from shortcuts via SSH passing in script parameters to control the activity. But I do invariably cd to a script directory first.

I’m just inputting the same command as I do in terminal from my Mac Mini.

The output after running at present:

What command would be required to change to the same directory?

Apologies for the basic questions!

That would be a cd followed by the directory path, though you could potentially also just use the full path to sky-remote-cli.

I’ve tried cd to the path of sky-remote-cli as well as cd ~htpc but no luck so far…

On your computer try running which sky-remote-cli and see what turns up. It’s possible that nom package is not installed globally and so it doesn’t find it when looking in (usually) /usr/bin

Edit: you can also try using the full path to run it

So, after the which sky-remote-cli I get:
/usr/local/bin/sky-remote-cli

I would try using that full path in your command over ssh

So now trying:
cd /usr/local/bin/
sky-remote-cli 192.168.0.16 1 1

Feeling pretty stupid right now :slightly_frowning_face:

I would just use the command

/usr/local/bin/sky-remote-cli 192.168.0.16 1 1

1 Like

That just gives me:

Break it down in your Shortcut. Step through your path and run an ls at each path component to check that the next part of the path is available.

So maybe run it 4 times with the following over the course of those three.

  1. ls /
  2. ls /usr/
  3. ls /usr/local/
  4. ls /usr/local/bin/

Each time check that the next entry in the path (right through to the Sky CLI app) is listed.