Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
aXiMus
Old
#1  
Junior Member - OP
Thanks Meter 5
Posts: 29
Join Date: Dec 2007
Default [Q] Posting Notifications from Shell

Is there anyway to post to the android notification bar from simple shell commands?

I have a script which I run using cron on my linux box which monitors some mission critical services for my business and I would like to port it to my Galaxy Nexus. It's a simple bash script which simply monitors the services with netcat.
I have tried a couple of market apps which don't work.
 
ell3
Old
#2  
ell3's Avatar
Member
Thanks Meter 21
Posts: 52
Join Date: Nov 2011
Location: Mu
If you consider installing SL4A on your phone, you have a very powerful environment to make your scripts and doing what you ask requires only a

Code:
droid.notify('title', 'message')
You could even have something like this

Code:
from socket import * 
import android, os, time, datetime

droid = android.Android()
UDPSock = socket(AF_INET,SOCK_DGRAM) 
UDPSock.bind(('',2800))
Volume()

while 1: 
    data,addr = UDPSock.recvfrom(4*1024) 

    if not data: 
        break 
    else: 
        droid.notify(str(addr[0]), data)   #Make a notify in the bar
        droid.makeToast(data) #Make a small msg
        droid.dialogCreateAlert('MSG_FROM:' + str(addr[0]),data)
        droid.dialogShow() #Big on screen alert
UDPSock.close() # rly?
Code is just a PoC... actually uses python and opens port 2800 UDP on your phone, if you send a packet via udp to your phone, a msg will be displayed (3 times in 3 different ways, unless you remove some line ). You could then make your PC scripts send a packet to your phone and have your notification displayed.

Look into this and this
I'm L.
The Following User Says Thank You to ell3 For This Useful Post: [ Click to Expand ]
 
aXiMus
Old
#3  
Junior Member - OP
Thanks Meter 5
Posts: 29
Join Date: Dec 2007
ell3,
Thanks for the quick reply. I think that's exactly what I was looking for!
Cheers!
 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...