Sublime Forum

SOLVED: Append outputs from differents exec commands

#1

Is there a way to append the output from two differents commands?

for example:

self.window.run_command("exec", {"cmd": cmd1})
self.window.run_command("exec", {"cmd": cmd2})

and the output in the console shows the info from cmd1 and cmd2

0 Likes

#2

You could use shell functions to make ST execute both programs in one “exec” call.

self.window.run_commnd("exec", {"shell_cmd": "{} & {}".format(cmd1, cmd2)})
4 Likes

#3

Thanks @FichteFoll that was exactly what I want!

Other question, maybe you can help me, do you know how can I get the output text and edit it? and at the same time get the return code of the execution?

0 Likes

#4

At that point, you should start looking into working with subprocess.Popen directly.

The exec command is useful only if you intend the user to see the external program’s output but do not intend to do anything with it yourself.
When you want to do work with the external program’s output, you need to call subprocess.Popen (or another function in the subprocess module) and take care of displaying the output to the user if you want to. The exec command source code should get you started on how to work with output panels. You can investigate that in Default/exec.py (using the PackageResourceViewer package).

3 Likes

Dump/Pipe contents of build command output from console to file
Correct way to use a complicated pipe in build system
#5

I’ll take a look. That info seems to solve my problem.

Thanks again!

0 Likes