Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ntfy background shell? #67

Closed
grkngls opened this issue Jun 18, 2016 · 6 comments
Closed

Using ntfy background shell? #67

grkngls opened this issue Jun 18, 2016 · 6 comments

Comments

@grkngls
Copy link

grkngls commented Jun 18, 2016

I want to use ntfy to notify me from my headless serve (ubuntu 14).
A script starts at inserting a disc in the drive
SUBSYSTEM=="block", KERNEL=="sr0", ACTION=="change", RUN+="/usr/local/bin/add-disc.sh"
In add-disc.sh i do some differnet things (in the backgrond -> headless) and want be notified via ntfy. All commandos in add-disc.sh works - not nfty.
Is there a parameter to let nfty work in background?

@grkngls
Copy link
Author

grkngls commented Jun 19, 2016

Ok I tried differnet things. I suppose ntfy don't send notification, if ntfy is called throug a second script.

First (bash) script start.sh:

#do anything
/usr/local/bin/second-script.sh

and the second script look like this:

#do anything
ntfy send "first thing done"

#do another thing
ntfy send "yeah. another thing done"

Is this an error on my side? Hope the question is not to silly. It's my frist bash script and I'm very new in ubuntu/bash.

@grkngls grkngls closed this as completed Jun 19, 2016
@grkngls grkngls reopened this Jun 19, 2016
@dschep
Copy link
Owner

dschep commented Jun 20, 2016

You say you're running this on a headless server. If that's the case you can only send notification using one of the remote backends (pushover, pushbullet, etc). I use Pullover(a pushover client) on my host machine to get notifications from a headless VM.

@ghost
Copy link

ghost commented Aug 27, 2016

I am unable to get ntfy working from a script launched by crontab on a headless debian 8.5 server. Additionally launching the notification script from another script isn't working.

Notify.sh
ntfy -b pushover -t 'Server Online' send hostname -I

quick test is to run below
/bin/bash ntfy -b pushover -t 'Server Online' send hostname -I

Output is:

user@server:~/bin$ bash ntfy -b pushover -t 'Router Online' send `hostname -I`
/usr/local/bin/ntfy: line 4: import: command not found
/usr/local/bin/ntfy: line 5: import: command not found
from: can't read /var/mail/ntfy.cli
/usr/local/bin/ntfy: ntfy: line 10: syntax error near unexpected token `('
/usr/local/bin/ntfy: ntfy: line 10: `    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])'

Not sure where to go from here because I've tried every variation of executing ntfy from bash scripts that I can think of. Any ideas?

@dschep
Copy link
Owner

dschep commented Aug 28, 2016

don't run it with bash (it's a python script). Those errors are from bash trying to interpret a python script

@ghost
Copy link

ghost commented Aug 28, 2016

Same problem running it from within a bash script executed by cron.

@tushev
Copy link

tushev commented May 15, 2022

I had to specify full path to ntfy in bash scripts executed by cron, i.e., for Ubuntu: /usr/local/bin/ntfy send test.

which ntfy will give you the correct path for your system.

@dschep dschep closed this as completed May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants