mdengler
|
2011-03-19
, 15:38
|
Posts: 74 |
Thanked: 25 times |
Joined on Jan 2010
@ Hong Kong, CHINA
|
#451
|
|
2011-03-25
, 02:09
|
Posts: 89 |
Thanked: 52 times |
Joined on Jan 2010
@ London, UK
|
#452
|
Hi Jgbreezer,
I didn't know this usage of function range(), it perfectly substitutes the code I wrote, please create a patch and post it here to be merged in the next version.
The Following User Says Thank You to jgbreezer For This Useful Post: | ||
|
2011-04-11
, 17:26
|
|
Posts: 159 |
Thanked: 53 times |
Joined on Jan 2011
@ Romania, Cluj-Napoca
|
#453
|
#!/bin/sh if [ `route | awk '/au/ {print $1}'` = default ]; then exit else run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Updating e-mail..." run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 sleep 10 run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive sleep 100 if [ `ifconfig gprs0 | awk -F " " '/s0/ {print $2}'` = Link ]; then run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"E-mail updated" fi
|
2011-04-12
, 10:39
|
Posts: 539 |
Thanked: 165 times |
Joined on Feb 2010
@ Berlin, Germany
|
#454
|
Also, I think the script itself has some problems because if I run it in terminal I get several "if" bugs and "sleep 100" and "sleep 10" erors.
Code:#!/bin/sh if [ `route | awk '/au/ {print $1}'` = default ]; then
Code:if [ `ifconfig gprs0 | awk -F " " '/s0/ {print $2}'` = Link ]; then
|
2011-04-12
, 14:43
|
Posts: 74 |
Thanked: 25 times |
Joined on Jan 2010
@ Hong Kong, CHINA
|
#455
|
First you should make sure the script is working correctly before trying to use it with some automated trigger like alarmed. In worst case you could shred your device this way if the script runs wild and gets started over and over again.
Then you should append the actual error messages to your post so one could help you on the point instead of guessing. Therefore all following hints are just guessed and might be wrong too.
#!/bin/sh # # n900 / maemo script # # Function: trigger an email fetch; connect to the internet if possible & necessary # # Copyright: 2011 Martin Dengler <martin@martindengler.com> # Dual License: MIT / GPL v3+ retrys=5 while [ $retrys -gt 0 ] ; do if /sbin/route | grep -q "^default " ; then break #...we are connected else run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd --print-reply /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 retrys=`expr $retrys - 1` sleep 5 fi done /sbin/route | grep -q "^default " || exit 1 run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Updating e-mail..." run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive sleep 120 # if we connected just for this, disconnect if [ $retrys -lt 5 ]; then run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi
|
2011-04-12
, 14:45
|
Posts: 1,680 |
Thanked: 3,685 times |
Joined on Jan 2011
|
#456
|
What you said.
Furthermore, here is an improved version of that script:
I have tested it and seems to work fine.Code:#!/bin/sh # # n900 / maemo script # # Function: trigger an email fetch; connect to the internet if possible & necessary # # Copyright: 2011 Martin Dengler <martin@martindengler.com> # Dual License: MIT / GPL v3+ retrys=5 while [ $retrys -gt 0 ] ; do if /sbin/route | grep -q "^default " ; then break #...we are connected else run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd --print-reply /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 retrys=`expr $retrys - 1` sleep 5 fi done /sbin/route | grep -q "^default " || exit 1 run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Updating e-mail..." run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive sleep 120 # if we connected just for this, disconnect if [ $retrys -lt 5 ]; then run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi
I removed the last "Email updated" because that's basically a lie (since we don't know that modest received that dbus message - see https://bugs.maemo.org/show_bug.cgi?id=7834 ), and I can't see the point of blindly sending such a message after just waiting two minutes.
|
2011-04-12
, 15:01
|
Posts: 74 |
Thanked: 25 times |
Joined on Jan 2010
@ Hong Kong, CHINA
|
#457
|
http://talk.maemo.org/showthread.php?t=68111
-________-
|
2011-04-12
, 15:03
|
Posts: 74 |
Thanked: 25 times |
Joined on Jan 2010
@ Hong Kong, CHINA
|
#458
|
|
2011-04-12
, 15:09
|
Posts: 1,680 |
Thanked: 3,685 times |
Joined on Jan 2011
|
#459
|
Also, do you think the dbus method actually works? There is some evidence ( https://bugs.maemo.org/show_bug.cgi?id=7834 ) that it might not.
|
2011-04-13
, 07:33
|
|
Posts: 159 |
Thanked: 53 times |
Joined on Jan 2011
@ Romania, Cluj-Napoca
|
#460
|
What you said.
Furthermore, here is an improved version of that script:
I have tested it and seems to work fine.Code:#!/bin/sh # # n900 / maemo script # # Function: trigger an email fetch; connect to the internet if possible & necessary # # Copyright: 2011 Martin Dengler <martin@martindengler.com> # Dual License: MIT / GPL v3+ retrys=5 while [ $retrys -gt 0 ] ; do if /sbin/route | grep -q "^default " ; then break #...we are connected else run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd --print-reply /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 retrys=`expr $retrys - 1` sleep 5 fi done /sbin/route | grep -q "^default " || exit 1 run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Updating e-mail..." run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive sleep 120 # if we connected just for this, disconnect if [ $retrys -lt 5 ]; then run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi
I removed the last "Email updated" because that's basically a lie (since we don't know that modest received that dbus message - see https://bugs.maemo.org/show_bug.cgi?id=7834 ), and I can't see the point of blindly sending such a message after just waiting two minutes.