executeCommand(commandOptions: CommandLineOptions)

termWidget.executeCommand({ cwd: './', args: ["dir"] });
When I write this
cmd will
cd “./” && cmd /C ““dir””
‘“dir”’ 不是内部或外部命令,也不是可运行的程序
或批处理文件。
what should i do

Hey @y912765390

it’s not quite clear what you’re trying to accomplish. What are you trying to do? Do you just want to execute dir in the current directory? You can actually just run termWidget.sendText("dir\r\n"). The \r\n part automatically executes the command.

I know what you mean.I know this.

I want to know how to use “termwidget. Executecommand” and how to use its second parameter

It’s a “bug” from Theia when interacting with cmd.exe: We escape everything passed to args: [...] but it seems to breakdown on commands like dir because those aren’t spawnable processes.

The following PR should fix that issue: process: fix `env` when building commands by vince-fugnitto · Pull Request #11609 · eclipse-theia/theia · GitHub

Until the PR I linked is merged, you should try the following:

termWidget.executeCommand({ cwd: './', args: [{ value: "dir", quoting: "escape" }] });

It’s not great but it has chances to work…

Thank you. I just want to understand this API because I know sendtext can be used

The type of this API is’ string [] ', so I wrote it that way
besides,I want to know if there is any method to receive the return message of terminal. Similar to onmessage (message = > {})

I find 'terminal-widget-impl ’
rpc.onNotification || waitForConnection ||connection.onmessage
All of these are OK, but they can’t get them from outside. They either can’t get them, or they can’t get protection. How can I use this connection outside Onmessage or rpc.onnotification

Do you absolutely need to interact with a terminal widget, or do you just want to issue commands to a shell?

I need to get the return information of the terminal widget and do something according to the return information

I don’t know how to fetch lines from the terminal widget beside looking at the termWidget.getTerminal() API, but you could use the underlying APIs used by terminal widgets to directly interface with a shell proxy instead of interfacing with a widget.

If you need your code to run in the frontend you can check this code.

Thank you very much. I have also read the code here, but I use 'terminalservice Newterminal 'to get the terminal widget. So I think she used ‘’* * *. Listen‘’to connect If I want to use this onconnection in the front end, I have no idea how to do it. Is there any way

Or do you mean that I can rewrite ‘terminalwidgetimp’ to throw an API so that I can connect this’ connection 'at the front end

I know ‘terminal widget impl’ this. Websocketconnectionprovider Listen (connection) can handle onmessage, but I can’t get this connection outside

I know this ‘websocketconnectionprovider ’ has an attribute ‘channelmultiplexer’, and the ‘channelmultiplexer’ has an attribute and a method ‘openchannels’ and’ getopenchannel ‘, but because it is based on the’ websocketconnectionprovider ', I can’t get it outside

I read the debug-session.tsx that you sent a reply. I think this is to establish a connection first Then create a new terminal and execute the same command as this connection. What I understand is that the terminal is displayed with the connection instead of intercepting the terminal widget. Is this the case with debug-session.tsx