I'm trying to open an app that listens to port 25 within a shell script. In order to listen to port 25, I need to run the app with sudo
. So I tried the following:
sudo open appThatNeedsPort25
It asks me for my password and opens the app. Problem is the app is NOT being run as root, so it is unable to listen to port 25…
What do I do to open an app from a shell script so that it can listen to port 25?
Best Answer
sudo -b
makes the application run in the background.Unlike with
sudo appThatNeedsPort25 &
, sudo itself will run in the foreground, so you'll have no issues with its password prompt. Note that sudo also has a-A
option to make it ask for a password through a GUI instead of in the terminal, you can use this whensudo
isn't running from a terminal.