Coder Social home page Coder Social logo

Comments (4)

jorangreef avatar jorangreef commented on July 22, 2024

Thanks @LouWii , you are welcome.

The reason for the multiple password prompts is because Ubuntu uses TTY tickets, so each separate shell session requires sudo.

sudo-prompt uses a privileged shell session on Windows and Mac, so your command should work fine there as is. On Linux, however, we are currently running the command directly using kdesudo or pkexec, so your second command would fail since it would be outside of the sudo session. I think this would be good to fix.

In the meantime, could you try: bash -c "command1; command2" as your command argument?

from sudo-prompt.

LouWii avatar LouWii commented on July 22, 2024

bash -c "command1; command2" does work. Thanks !

What would you recommend as a long-term fix for Linux ? Use something different than kdesudo or pkexec ? I know Linux a bit but this goes beyond my knowledge.

from sudo-prompt.

jorangreef avatar jorangreef commented on July 22, 2024

Great! I would like to update the Linux component of sudo-prompt to do something similar by default.

from sudo-prompt.

franciscop avatar franciscop commented on July 22, 2024

What about something like this?

const sep = '~SEPARATOR~';

const cmd = (...commands) => {
  const separated = commands.join(` ; echo "${sep}"; `);
  return (await exec(`bash -c '${separated}'`)).split(sep);
};

Then to use it you can do:

const [root, echo, home] = await cmd('ls /', 'echo "Hello world"', 'ls ~/');

from sudo-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.