How can I start a terminal and a command using the IShellTerminalServer?

What I am trying to do is to start a terminal on the node side, before any client is connected. This works and I am using the IShellTerminalServer for this. From the frontend I am then consuming a service to get the terminalId which I then connect to.

My question now is, how can I execute a command in the terminal on the node side, so once I created a terminal via the IShellTerminalServer?

Thanks in advance for your help!

[original thread by Dominic E.]

You can use ProcessManager to get an access to an undetlying process instance and call write on it.

const id = this.shellTerminalServer.create({ ... }); 
const process = this.processManager.get(id);
process.write('echo "Hello World"\n');

[Dominic E.]

Ah! That’s cool. Thanks so much @anton-kosyakov

Hi @ akosyakov, why i can not find ‘write’ in ‘Process’?

Do you mean ‘TerminalProcess’? But ‘this.processManager.get(id)’ returns a ‘Process’, which can not assign to ‘TerminalProcess’.