0

I have a program run from the command line in OSX that I want to be able to pop up messages occasionally by running something like this:

osascript -e "display dialog \"Message\""

This works fine if I never change users. If I su other_user and run the program on the command line, it continues to work. But if I su - other_user, it no longer works, saying error retrieving current process.

How can I get display dialog to run even after changing users with su -l?

pythonic metaphor
  • 10,296
  • 18
  • 68
  • 110
  • "How can I get `osacript` to run" I think you'll find that `osascript` runs just fine. It's `display dialog` that's the problem. – matt Apr 20 '16 at 19:05
  • @matt I did see that question, but it has no answers and also there is an additional error message. Since, in my limited case, I only get the `current process` error and since I can run it after `su` but not `su -`, there might be an easier solution around in my limited case. – pythonic metaphor Apr 20 '16 at 19:06
  • @matt you're right, changed question wording to reflect that. maybe i should change question title as well? – pythonic metaphor Apr 20 '16 at 19:07
  • "there might be an easier solution" I don't think so. The trouble is that `display dialog` needs to appear somewhere. You're not giving it enough info to do that. You might try `tell application "Finder" to display dialog...` but I don't guarantee anything. – matt Apr 20 '16 at 19:07
  • `display dialog` alone works both as original user and after `su` without prompting for password. If I add `tell app \"blah\" to ...`, it works for original user, requires entering password after `su` to different user, and fails with a different error after `su -` – pythonic metaphor Apr 20 '16 at 19:10
  • Well, I can't say I'm surprised. :( – matt Apr 20 '16 at 19:19

0 Answers0