I did it like this:
noc=`$sql /private/var/mobile/Library/SMS/sms.db 'select address from message where address=5551515'`;
if [ "$noc" = 5551515 ]
then
$playaudio $NOCaudiofile &
Seems to work! But then you have to delete the message to get the audio to stop, so I need to add the count in there too.
OK... DONE for now... With CUSTOM Alerts!
This script will check to see if you get a match (51511212 is the number im matching in sample) and then repeat every 10 seconds. Nice for people monitoring servers. If you get a NEW text message thats NOT a match then it will simple play your default SMS sound in settings | sounds on the iPhone.
I left the "Count" so it will stop alerting when you view the Text Message, otherwise it continues to alert until you delete the message. Looks like I may expand this a bit more, but for now I have repeating NOC (Network Operations Center alerts).
#!/bin/sh
smsnpath=/usr/bin/smsnotify
sql=$smsnpath/sqlite3
playaudio=$smsnpath/play
nocaudiofile=$smsnpath/NOCalarm.m4a
while test 1
do
n=`$sql /private/var/mobile/Library/SMS/sms.db 'select count(*) from message where flags=0'`;
noc=`$sql /private/var/mobile/Library/SMS/sms.db 'select address from message where address=5151212'`;
if [ "$n" -gt 0 ] && [ "$noc" = 51511212 ]
then
$playaudio $nocaudiofile &
fi
sleep 10
done
Better ways of doing this? Please share...
Quote:
Originally Posted by bhuga
...The problem that I haven't solved yet is that I can't find a way to make the phone either not sleep or wake up at a given time. Even with launchd running the daemon properly, the phone will still sleep and that's that. I've tried it with launchd running a script that loops, simply running that looping script, and by having launchd run a script that checks once and exits. Nothing will keep the phone awake.
I've done a lot of searching and have not found a way to make the phone stay awake--even people doing apps at the UI level are having trouble. You can, if you're diligent about turning the phone off, turn off auto-locking any any number of previously mentioned methods will work, using the stuff I've just posted. But that's no fun!
|
Seems the receipt of an SMS trigers the phone out of "deep" sleep and my repeat alarms are working. Had my phone sleeping over ten minutes and send a test, seemed to work fine.