skip to Main Content

i’m trying to write a python script which can execute two commands

sudo docker run --network=host --volume /home/villas/results:/villas/build/results --volume /home/villas/Docker-containers/webrtc-rtt.conf:/config.conf --privileged registry.git.rwth-aachen.de/acs/public/villas/node:master node /config.conf

and

sudo docker run --network=host --volume /home/villas/results:/villas/build/results --volume /home/villas/Docker-containers/webrtc-loopback.conf:/config.conf --privileged registry.git.rwth-aachen.de/acs/public/villas/node:master node /config.conf

in two different terminals at the same time.
So what the script needs to do is, execute the first command in one terminal, and then create a new parallel terminal and the second command will be execute in second terminal.

To create a split terminal manually, I have to press ctrl+shift+5
But instead I want let my python script to do this job.
Is there any way to code this into the python script?

2

Answers


  1. If you want to do this at the VS Code level, I’m pretty sure you can’t (invoke general VS Code commands from terminal) right now. See Possible to invoke a VSCode extension command from command line?.

    If you want to do this within a terminal in VS Code, look into terminal multiplexer software like tmux.

    Alternatives:

    • Drive things from VS Code tasks. The simple thing to do would just be to create a task for each command and then a compound task that depends on them. You’d have to drag the terminal out to create the split view yourself though.
    • Drive things from a VS Code keyboard shortcut. runCommands and Shortcut for running terminal command in VS code would help with that, as well as the respective commands for creating and focusing terminals.
    Login or Signup to reply.
  2. Try this tasks.json:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Task One",
                "type": "shell",
                "command": "sudo docker run --network=host --volume /home/villas/results:/villas/build/results --volume /home/villas/Docker-containers/webrtc-rtt.conf:/config.conf --privileged registry.git.rwth-aachen.de/acs/public/villas/node:master node /config.conf",
                "presentation": {
                    "group": "groupA"
                }
            },
            {
                "label": "Task Two",
                "type": "shell",
                "command": "sudo docker run --network=host --volume /home/villas/results:/villas/build/results --volume /home/villas/Docker-containers/webrtc-loopback.conf:/config.conf --privileged registry.git.rwth-aachen.de/acs/public/villas/node:master node /config.conf",
                "presentation": {
                    "group": "groupA"
                }
            },
            {
                "label": "Run Both Tasks",
                "dependsOn": [
                    "Task One",
                    "Task Two"
                ]
            }
        ]
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search