How do I run an application as root?

I want to run this application as root because I want to allow it to listen on a port lower than 1024. It is a regular application I am used to running by double clicking it in the Finder. In the Terminal, I have su'ed to root, and I try to run it by typing ./Warcraft\ III, however I receive the error:
./Warcraft III: cannot execute binary file

The file has the correct permissions (755), and it is not a directory (and does not have a .app extension). I am used to double clicking this file in Finder to start it.

Thank you

Mac Mini, Mac OS X (10.4.3)

Posted on Dec 4, 2005 2:37 AM

Reply
15 replies

Dec 4, 2005 6:29 AM in response to ToadX

Hi ToadX,
If it's a cocoa app, you have invoke the executable inside the MacOS directory in the app bundle. However, since the error message said that Warcraft\ III was a binary, I assume that it's a Carbon app. You should be able to run it as root with:

sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMA pp /<Absolute>/<Path>/<to>/Warcraft\ III

Note that the above command is essentially all on one line even though the browser and terminal will certainly have to wrap it.
--
Gary
~~~~
alimony, n:
Having an ex you can bank on.

Dec 5, 2005 5:32 PM in response to Boyd

Hi Boyd,

> is there a way to run an application starting from
Finder as superuser


I may not be understanding what you mean as root is the superuser but there are a variety of ways to make script commands "double-clickable". You can put the following in an AppleScript:

do shell script "/System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFM App /<Absolute>/<Path>/<to>/Warcraft\ III" with administrator privileges

Save the AppleScript as an application and you will be able to double-click on it.

You can save the shell script with a filename suffix of ".command" and it will be double-clickable.

Finally, use Sveinbjorn Thordarson's Platypus to turn the script into a double-clickable application.
--
Gary
~~~~
Don't take life seriously, you'll never get out alive.

Dec 6, 2005 10:44 AM in response to Gary Kerbaugh

Just a reminder (since Boyd's profile lists 10.3.9). AppleScript's "do shell script ... with administrator privileges" in "Panther" uses the insecure method of echoing / piping the "admin" password to ' sudo -p' so that any other user on the computer could potentially see the password in plain text by using ' ps -ax' while the command is executing (or while the programme is running in this case). The suggested workaround is to run the command in the background by appending " &" to the unix part of the AppleScript command.
http://forums1.macosxhints.com/showthread.php?t=14696

I have been told that this is no longer a problem in "Tiger".

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I run an application as root?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.