View Single Post
Old 12-24-2011, 12:05 PM   #5
inameiname
Groupie
inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.
 
Posts: 156
Karma: 20390
Join Date: Feb 2009
Device: none
Quote:
Originally Posted by ixtab View Post
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.
Thanks for the suggestion. Your TEMPLATE idea is interesting.

Fortunately, I did figure out another way to do this. I will show you what I did in the next post.

BTW, I think not having 'mntroot rw' and 'mntroot ro' in the script was the issue. I say this only because that is what resolved the 'failure' message I kept getting with the updated script.

Last edited by inameiname; 12-24-2011 at 12:16 PM.
inameiname is offline   Reply With Quote