I am trying to make a script that automatically launches Thinkorswim from a simple command in the terminal. I wrote an incredibly simple script:
#!/bin/sh
sh /opt/thinkorswim/thinkorswim
This is in the /usr/bin directory so I can just type thinkorswim in the terminal. The application requires sudo to run, and I want to make it so I don't have to type in sudo, and then my password. This is partly just for speed and convenience, and partly because I want to be able to launch it through dmenu on i3.
- I have tried putting
echo password | sudo sh...in the script. This does not work. - I have tried adding
username ALL=(ALL) NOPASSWD: /opt/thinkorswim/thinkorswimto sudoers, after addingsudobeforeshin the script. This does not work. - I have tried adding
username ALL=(ALL) NOPASSWD: /usr/bin/thinkorswimto sudoers. I quickly realized that I would still need to typesudobeforethinkorswimwhen lauching it through the terminal, and this still does not work through dmenu.
I restarted my computer after I modified sudoers each time. I am running Ubuntu 20.04 LTS, with i3wm version 4.17.
TL;DR: I am trying to run a script with sudo permissions without actually having to type sudo and my password. How do I do this?
Any help is appreciated, thanks.
sudo? If you putusername ALL=(ALL) NOPASSWD: /opt/thinkorswim/thinkorswiminsudoers, then you need to be usingsudo /opt/thinkorswim/thinkorswimsudo sh /opt/think..., that way sudo was being executed on the/opt/thinkorswim/thinkorswim.sudois executed onshin that case.shprogram to execute/opt/thinkorswim/thinkorswim. I thought I was usingsh, with sudo permissions, to launch/opt/thinkorswim/thinkorswim