Page 1 of 1

Running shell script without Terminal window

PostPosted: Fri Aug 27, 2021 8:26 am
by davinci
What is the best way to run a shell script?

Right now I use open file to run it, but it always opens a Terminal window. I prefer not to show that window.
Ist this possible and how?

Re: Running shell script without Terminal window

PostPosted: Fri Aug 27, 2021 8:54 am
by jay (support)
Use the Run Shell Script action.

Re: Running shell script without Terminal window

PostPosted: Fri Aug 27, 2021 9:04 am
by davinci
Makes sense :)

I just ran into the next question.

How can I see if it is still running and how can I interrupt this shell script from Indigo?

Re: Running shell script without Terminal window

PostPosted: Fri Aug 27, 2021 10:17 am
by jay (support)
Using this action, you can't. In fact, building the capability to kill a shell script that you start is going to be a non-trivial exercise. You might want to reconsider the architecture of your solution if that's really a requirement - see if there's a better way of solving the problem.

Re: Running shell script without Terminal window

PostPosted: Fri Aug 27, 2021 2:31 pm
by berkinet
To kill a command you started with “run shell script”:
Code: Select all
ps ax | grep <command name>

That will give you the process id (pid), then just kill it.
If you will be doing this often, then have your script or program save its pid somewhere, Typically, that would be in /vár/run with an extension of .pid.

You can also create a shell script to kill your command, either by grepping t he output from ps for the pid, or reading the .pid file,and then kill it.