How to retrieve the output of a task?

I configured a shell task to echo hello:

I noticed a similar post but it just refers to get task quit code from the frontend TaskService. I think maybe I should get the result of the task from the backend TaskServer. But I didn’t find a way to retrieve the output (the hello string in this example).
Any help? Really appreciate!

Hi @inlann,

Shell based tasks like yours always create a terminal associated with it. You can use the TaskService to start a new task, which returns some info about the running task (as a TaskInfo object) which in turn contains the terminal id. With that terminal id you can use the TerminalService and ask for the actual terminal that runs your task (using TerminalService.getByTerminalId).

Using that terminal, you can hook into the onData event which fires every time the terminal receives new text/data. Afterwards, you can do with whatever you want with that string. There no way that I’m aware of to just retrieve the whole task output (or terminal output for that matter).