View Single Post
Old 12-24-2011, 11:34 AM   #4
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by inameiname View Post
Thanks for the suggestion, unfortunately it doesn't work either.

I didn't try "sed -i -e 's/.../'" yet. What would that do, and how would I write it in this case?
It's actually just the long form of your command, i.e. explicitly saying "the s/.../ part is the expression to be evaluated". try sed --help on your device, you'll find the info there. I actually wasn't even aware that one could omit the "-e".

Anyway, I just ran this on the device, and sed is working as it should.
Code:
[root@kindle tmp]# echo 12345600789 > test.txt
[root@kindle tmp]# sed -e 's/600/900/' test.txt 
12345900789
I looked at your code again, and there is something fishy: if the backup file doesn't exist, it is created from the current configuration. It doesn't necessarily contain "600", though. So maybe this is why it's failing.

I would suggest to rewrite the thing to a simpler and "less dangerous" variant, something like:
Code:
if [ -f /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.TEMPLATE ]
then
	sed -e 's/_TIMEOUT_/900/' /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.TEMPLATE > /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout
	/etc/init.d/powerd restart
fi
exit
You would create the TEMPLATE file exactly once (maybe on installation, whatever), and instead of putting some exact number in there, put _TIMEOUT_ in the respective place. This is the pattern that'll be replaced. I also suggest not to duplicate the logic over 5 files, but create it once, and parameterize it... Along the lines of "set_timeout.sh 900". Instead of hard-coding the value, you'd just use $1 in the script.
ixtab is offline   Reply With Quote