Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

How to run multiple commands without requiring password every time #141

Open
tutiplain opened this issue Jul 26, 2021 · 6 comments
Open

Comments

@tutiplain
Copy link

Hi! I just began using sudo-prompt and while it works for me, I find it has the drawback of asking me for the password for every single command I run with it. Is there a way to get it to remember the password?

@nobody-sun
Copy link

I have same problem,Looking forward to a reply

@tutiplain
Copy link
Author

@nobody-sun It looks like we won't be getting an answer here. I found a workaround that might work depending on your needs. Instead of running multiple commands, you can concatenate your commands into a string separating them with && and do a single call to sudo-prompt. This will allow you to call multiple commands and entering a single password. This helps if all the stuff you need to do can be done with OS commands. If you need run separate commands at different points in your app, then this approach won't help. I'm still looking for alternatives. If I find any I'll post here again.

I also tried another library, electron-sudo. That one did not work at all for me.

@PeterKieu
Copy link

I think that we should use sudo to create launchd job, it can help once sudo dialog for multiple commands.

@night-peiqi
Copy link

I have same problem,Looking forward to a reply

@tutiplain
Copy link
Author

@Awn-Alice Your best bet at this point is to concatenate your commands using && and running them all at once. For me this required refactoring some operations done in code, to doing them in bash commands. It it not a pretty solution, but it worked for what I was doing. Creating a launchd job sounds like an option, but it can be tricky to use, and its behavior can change on future Mac OS releases.

@night-peiqi
Copy link

@tutiplain Thank you for your reply, but this scheme may not be suitable for my situation. I may need to modify hosts file frequently. However, every time I change it, I have to enter the password

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants