1

I am making a shell script that works great on its own, but does not work correctly when packaged with Platypus. It does not want to execute sudo, and a few other system commands. Are there any work arounds to this?

Note: This is when you select the "Run with Administrator privileges" option. Also, this is an answer-it-yourself question, since I would imagine someone else out there would have this issue as well.

2 Answers 2

1

You can also use the osascript to launch the application. This ensures sudo access.

osascript -e "do shell script \"/path2/shellscript.sh $*\" with administrator privileges"

You can put this in another shell script to call your script. Or directly run your required command within the quotes.

This is better since you don't have to rely on /usr/bin/sudo being run recently or not

2
  • I actually learned about that command just a little while ago while making an app. Thanks for responding.
    – Flare Cat
    Oct 31, 2016 at 20:45
  • Good for you then ...Cheers Nov 3, 2016 at 18:45
0

I figured out the issue, it appears Platypus does not recognize some system commands, even though they are in its $PATH. In order to use these system commands, you have to list their absolute path.

So, in sudo's case:

/usr/bin/sudo <commmand>

Or, in cp's case:

/bin/cp <arguments>

3
  • 2
    Did this actually work? The Platypus documentation says you cannot use sudo. "Platypus scripts must not use the 'sudo' command. This causes the script to prompt for input via STDIN, and since none is forthcoming, the application will hang indefinitely."
    – Eugene
    Mar 9, 2016 at 15:32
  • 1
    What I found is that sudo will work ONLY if the user has recently run a sudo command outside of your app, like in a Terminal window. Then the sudo session is still active, and sudo will work from within Platypus.
    – Eugene
    Mar 9, 2016 at 15:40
  • @Eugene It worked for me, but maybe that is because I might have run sudo in a terminal before that.
    – Flare Cat
    Mar 9, 2016 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .