Skip to content

Extension that executes shell or python code #202

Closed
@luis-chaves-visa

Description

@luis-chaves-visa

Problem

I'd like to create an extension that runs some shell or python code. From what I've been able to find (mainly this: https://github.com/enlznep/jupyterlab-shell-file/blob/master/src/index.ts) and a failed attempt at using child_process or zx from the src/index.ts file I have not managed to execute any shell code from an extension. I am trying to replicate the toolbar button example but executing some shell code (could be python too - but ideally shell) when the button is clicked

Proposed Solution

I have also tried adding the following (to no success):

const { exec } = require("child_process");

exec("ls -la", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
});

Any help is appreciated, also I'd love to see an example of this feature if it's possible at all

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: AnsweredQuestion answered that will be closedenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions