Execute shell script in debug mode

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

To execute a shell script and a Python application in the same shell session while debugging with Visual Studio Code using the Torizon extension, you’ll need to adjust the launch.json configuration file. This file dictates how your application is launched during a debugging session.

Here’s how you can integrate your shell script execution into the debugging process:

  1. Open the launch.json file: This file is typically found in the .vscode directory of your project. If it doesn’t exist, you can create it using the Visual Studio Code command palette by selecting “Torizon: Configure Debugging”.

  2. Modify the launch.json file: Ensure the shell script runs before the Python application by setting up a preLaunchTask or modifying the program and args fields. Here’s an example configuration:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Python: Remote Debug",
          "type": "python",
          "request": "launch",
          "program": "${workspaceFolder}/src/main.py",
          "args": ["--no-sandbox"],
          "preLaunchTask": "Run Shell Script",
          "justMyCode": true
        }
      ],
      "tasks": {
        "version": "2.0.0",
        "tasks": [
          {
            "label": "Run Shell Script",
            "type": "shell",
            "command": "src/start.sh"
          }
        ]
      }
    }
    
  3. Ensure the shell script is executable: Make sure start.sh has the correct permissions by running chmod +x src/start.sh in your terminal.

  4. Start the debugging session: With these configurations, the shell script will run first, followed by the Python application, allowing you to interact with your USB3 camera as needed.

I hope this helps you set up your debugging environment effectively.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

How to execute typical Linux commandw on Torizon.