sheagcraig / yo

Send Notification Center messages from the command line
Apache License 2.0
383 stars 44 forks source link

Unable to call bash scripts as bash_action #16

Closed iJake closed 8 years ago

iJake commented 8 years ago

--bash_action 'bash /PATH/TO/openTest.sh' or any variation does not work. Is it possible to open a script as the bash action and if so what would the syntax be?

sheagcraig commented 8 years ago

Can you confirm that the script in question has the correct permissions? Prior to the edit, it looked like it was inside of a home directory. So can the intermediary directories be traversed? Which user account is executing yo (presumably root?)

The script itself needs execute permissions, and it needs to correct shebang as well (#!/bin/bash in this case).

Are all of those things as they should be?

iJake commented 8 years ago

Yes, root via your Python script from Casper. I made sure the script was +x and it already had the shebang this time but same result. Script is only in my home folder while testing.

sheagcraig commented 8 years ago

Hey @iJake. So there has been a lot of issues getting management tools to run Yo. I've got a testing branch that uses a combination of LaunchAgents and LaunchDaemons to (hopefully) ensure the absolute correct execution environment so that the notifications definitely go off.

It does require the Luggage to build the installer package, and a restart after installation to get the LD and LA stuff started. Afterwards, it should be possible to run /usr/local/bin/yo -t 'my notification' (plus whatever other flags you want) as the root user (i.e. the user the Casper agent runs as) and it will fire the notification correctly. If there's a user logged in, it should activate right away; otherwise at their next login.

Of course it's in testing at the moment. But I think the key difference here is that it ensures that the yo app is run by the current console user, rather than as root, which is usually the issue with running Yo from Casper.

iJake commented 8 years ago

We can definitely test that out. Of note, the notification fires off just fine but the button seemingly does nothing when having it call a script.

iJake commented 8 years ago

Figured out what the issues was. Your python script uses the --bash_action flag but for whatever reason that isn't working in the binary. -B still works.

iJake commented 8 years ago

The above was not the actual issue. Didn't realize the script was being run as the user and not root when called by Casper. Writing the script for the user context resolved the issues.