Executing bash commands (THE BEST WAY)

I having an use case to execute bash commands from an extension.
I found 2 options

  1. Using a server extension and subprocess module
  2. using the “new-terminal” command and passing “initialCommand” parameter.

I find the second one much easier, but I am not sure which would be the best practice ?

1 Like

You cannot rely on the second one (new-terminal) because the administrator might have disabled the terminals, so your extension may not work for some users.

While for the most part using a server extension is the best option, if you really do not want to do so, you could create a kernel connection and send some Python code which uses subprocess; there are a few extensions which communicate via kernel comms like that but it is also assuming that you will always have a certain version of a specific Python kernel available (which is not guaranteed - it can be uninstalled by administrators if they like so).

1 Like