Notices


Reply
Thread Tools
Posts: 526 | Thanked: 99 times | Joined on Sep 2009
#41
Indeed I'm happy to work on a little app now that I have the base of the code :-)

P.S it will take time, cause I'm new to Maemo dev. but I will try and app name searching as well.
__________________
Christopher Stobbs

My Blog
 
Posts: 9 | Thanked: 0 times | Joined on Feb 2010
#42
Let me know if you got it to work - this is just a little Bash script to do the work, basically this is what it does:

1. execute hcitool command to get a list of all devices
2. use the awk to filter out the lines with 'BD Address' in it
3. use grep to see if we have a match
4. use dbus-send to display an alert if there is a match

Cheers, Arne
 
Posts: 526 | Thanked: 99 times | Joined on Sep 2009
#43
after I've moved it to ~/
I then ran you chmod 755 ~/N900finder.sh

Then when I run
~/N900finder.sh
I get on the next line
/bin/sh: /home/user/N900finder.sh: not found

am I doing something wrong?
__________________
Christopher Stobbs

My Blog
 
Posts: 9 | Thanked: 0 times | Joined on Feb 2010
#44
Originally Posted by stobbsc View Post
after I've moved it to ~/
I then ran you chmod 755 ~/N900finder.sh

Then when I run
~/N900finder.sh
I get on the next line
/bin/sh: /home/user/N900finder.sh: not found

am I doing something wrong?
the path to bash in the first line is prob. incorrect. just try placing sh in front like:

sh ~/N900finder.sh

and it should work.

Last edited by robota; 2010-02-09 at 18:53.
 
Posts: 526 | Thanked: 99 times | Joined on Sep 2009
#45
oKI added another lap to the code then typed this:
sh ~/N900finder.sh

Then it returns this:
: not found N900finder: line 4:
: not found N900finder: line 4:
__________________
Christopher Stobbs

My Blog
 
Posts: 9 | Thanked: 0 times | Joined on Feb 2010
#46
OK, without modification it doesn't compain?

Line #4 should read like:

grep '00:BD:3A\|00:BD:3B'`;

Notice the \| as a separator and the '`; (quote, backtick, semicolon) at the end of the line. You should be able to add as many laps as you like as long as they have the \| in between. If you still have troubles pm me as it might be out of scope to discuss that here - all I can say is that the code runs on my N900 ... or mail me: arne at robota dot nl.
 
Lord Awesome's Avatar
Posts: 47 | Thanked: 24 times | Joined on Nov 2009 @ Bolton, United Kingdom
#47
Originally Posted by robota View Post
OK, without modification it doesn't compain?
I had the same issue as above, so I trimmed the whitespace and took the line breaks out and it works.

Code:
#!/bin/bash
a=`hcitool scan --class | awk '/BD Address/ {print substr($3,0,8)}' | grep '00:BD:3A\|00:BD:3B'`;
echo $a;
if [ "$a" ]
then
dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:'Pizza! N900 here!' uint32:0 string:'OK'
fi;
 
Posts: 526 | Thanked: 99 times | Joined on Sep 2009
#48
I copied the code above and added one more section so it look slike this:

#!/bin/bash
a=`hcitool scan --class | awk '/BD Address/ {print substr($3,0,8)}' | grep '00:BD:3A\|00:BD:3B\|00:21:9E'`;
echo $a;
if [ "$a" ]
then
dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:'Pizza! N900 here!' uint32:0 string:'OK'
fi;
and I get the following errors:
:not found N900finder.sh:line 2:

:not found N900finder.sh:line 3:
:not found N900finder.sh:line 7: syntax error: "fi" unexpected (expecting "then")

Please not this when I'm not expecting to find a device. perhaps thats why there is an error, could someone try my code please.
__________________
Christopher Stobbs

My Blog
 
Posts: 9 | Thanked: 0 times | Joined on Feb 2010
#49
Add the path to the correct directory for the commands hcitool, awk, grep, echo and dbus-send like:

/usr/bin/hcitool
 
Lord Awesome's Avatar
Posts: 47 | Thanked: 24 times | Joined on Nov 2009 @ Bolton, United Kingdom
#50
Originally Posted by stobbsc View Post
I copied the code above and added one more section so it look slike this:



and I get the following errors:
:not found N900finder.sh:line 2:

:not found N900finder.sh:line 3:
:not found N900finder.sh:line 7: syntax error: "fi" unexpected (expecting "then")

Please not this when I'm not expecting to find a device. perhaps thats why there is an error, could someone try my code please.
Your addition works for me. What editor are you using to create N900finder.sh?
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 21:28.