Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,742,816 Members 38,626 Now Online
XDA Developers Android and Mobile Development Forum

[Guide][init.d]How to run init.d scripts on boot + Best Battery Life

Tip us?
 
gershee
Old
#31  
gershee's Avatar
Senior Member
Thanks Meter 584
Posts: 1,531
Join Date: Oct 2006
Location: Miami, Florida
Quote:
Originally Posted by sfhub View Post
The main issue is usually Windows uses CR-LF (Carriage Return + Line Feed) special characters to terminate a line.

Unix/Linux uses LF (Line Feed) to terminate lines.

Mac uses CR (Carriage Return) to terminalte lines.

These special characters cause issues with scripts being interpreted properly. There is also a problem with certain versions where the native text is unicode, which is a multi-byte character set. These characters will look pretty messed up on a single-byte system.

I'm sure you've also taken unix log files and viewed them on windows and just seen a jumbled mess of characters. That is because the LF by itself is not seen as a signal for a newline in windows and basically the whole log file is one big line.

If you want to write your scripts on windows, I suggest you use a text editor which knows how to convert the CR-LF and LF or you use utilities that can convert. Personally I use emacs but I am very old school.

You can find the DOS2UNIX and UNIX2DOS utilities on this page:
http://www.bastet.com/

They will convert the CR-LF and LF so the files can be read properly.

Use DOS2UNIX if you write your script in notepad, then want to move it to Linux/Android. Use UNIX2DOS if you have a file generated on Linux/Android and you want to view it in Notepad.
i've kind of used both mac - text edit and root explorer, so there could be some truth to this. i'll try using the above posted zip.. thanks guys.. appreciate the help.. just frustrating..
Samsung Epic 4G Touch (E4GT)

"if i'm too drunk to walk, i rock a party on crutches"
 
sfhub
Old
#32  
Recognized Contributor
Thanks Meter 6830
Posts: 4,757
Join Date: Oct 2008
Quote:
Originally Posted by gershee View Post
so i showed both my scripts. and the permissions.
and if you see the result of the test script, it does create a file, but 0kb with nothing in it.
Can you use the 0test file kobridge attached to his post above? I verified that it has the proper LF for unix (and I ran it on my phone and received output)

One symptom of CR-LF and LF problems is when the first command runs but nothing after it will run because the shell interpreter thinks there is an error with the run-on line and the unexpected carriage return.

That might be what is happening in your case, because when you "touch" a file, you create a 0 length file if the file isn't present and if it is, it updates the time stamp. That seems to fit your symptoms.
Disclaimer: No touchscreens were harmed nor injured during the creation of this post. GPS units were all treated ethically and humanely.
Signed: People against misbehaving Nexus 7 2013s
 
gershee
Old
(Last edited by gershee; 22nd April 2012 at 10:12 PM.)
#33  
gershee's Avatar
Senior Member
Thanks Meter 584
Posts: 1,531
Join Date: Oct 2006
Location: Miami, Florida
Quote:
Originally Posted by kobridge View Post
OK. I ran the test script as in my op section against init.d script and it ran ok.
(To make sure, I deleted previous output file). Just like I said in OP, you need to really careful when you create a file or edit. If you use the file editor from PC or use ES File explorer, there would be some special characters in the script file (hidden). This hidden characters are forgiven in SManager but not in shell script.
So, use some file editor something like root explorer text editor to create a shell script file.

For your convenience, I attached test script file that I just tested. Hope this help.
OK. used your zip. extracted file. put in /system/etc/init.d and changed permissions to 755. rebooted. same thing..:what:
think I'm gonna wipe and start fresh. I dunna. I'm in codename with fd19 kernel.
here's screenies..



its weird. even when I delete the file in root explorer, if I refresh the directory it pops up with 0kb immedietly.. wth is going on..

---------- Post added at 05:09 PM ---------- Previous post was at 05:07 PM ----------

Quote:
Originally Posted by sfhub View Post
Can you use the 0test file kobridge attached to his post above? I verified that it has the proper LF for unix (and I ran it on my phone and received output)

One symptom of CR-LF and LF problems is when the first command runs but nothing after it will run because the shell interpreter thinks there is an error with the run-on line and the unexpected carriage return.

That might be what is happening in your case, because when you "touch" a file, you create a 0 length file if the file isn't present and if it is, it updates the time stamp. That seems to fit your symptoms.
ahhhhh!
just looked in /etc/init.d (not /system) and i found the file also!!
i must have tried doing this last night before bed!!
deleted the file and rebooting now..

EDIT:
nope same thing. guess the system/etc/init.d files are copied to /etc/init.d on boot..
Samsung Epic 4G Touch (E4GT)

"if i'm too drunk to walk, i rock a party on crutches"
 
sfhub
Old
#34  
Recognized Contributor
Thanks Meter 6830
Posts: 4,757
Join Date: Oct 2008
Quote:
Originally Posted by gershee View Post
its weird. even when I delete the file in root explorer, if I refresh the directory it pops up with 0kb immedietly.. wth is going on..
Well either there is something recreating the file or the file is being prevented from being deleted. When the new file comes up, does it have the same timestamp or is it a newer timestamp?

If the former, then it is being prevented from being deleted. If the latter, then it could be recreated or there is some process that keeps touching the file.

---------- Post added at 09:12 PM ---------- Previous post was at 09:11 PM ----------

Quote:
Originally Posted by gershee View Post
ahhhhh!
just looked in /etc/init.d (not /system) and i found the file also!!
i must have tried doing this last night before bed!!
deleted the file and rebooting now..
/etc is usually a symbolic link to /system/etc

so basically /etc/init.d is the same directory as /system/etc/init.d (I don't mean same as in a copy, I mean they are physically the same directory)

---------- Post added at 09:16 PM ---------- Previous post was at 09:12 PM ----------

BTW I think it is worth looking into why the file keeps reappearing. It could give some clues what is going on.

Is it possible both SManager and init.d are trying to run the same script and they are stomping on each other?
Disclaimer: No touchscreens were harmed nor injured during the creation of this post. GPS units were all treated ethically and humanely.
Signed: People against misbehaving Nexus 7 2013s
The Following User Says Thank You to sfhub For This Useful Post: [ Click to Expand ]
 
gershee
Old
#35  
gershee's Avatar
Senior Member
Thanks Meter 584
Posts: 1,531
Join Date: Oct 2006
Location: Miami, Florida
Quote:
Originally Posted by sfhub View Post
Well either there is something recreating the file or the file is being prevented from being deleted. When the new file comes up, does it have the same timestamp or is it a newer timestamp?

If the former, then it is being prevented from being deleted. If the latter, then it could be recreated or there is some process that keeps touching the file.

---------- Post added at 09:12 PM ---------- Previous post was at 09:11 PM ----------


/etc is usually a symbolic link to /system/etc

so basically /etc/init.d is the same directory as /system/etc/init.d (I don't mean same as in a copy, I mean they are physically the same directory)
1st, yes same timestamp. 22 apr 12 14:59:00
2nd, yes this makes sense.. i though it was something like this, i was just hoping i found the mistake i must have made..
3rd, at first i tried using the new script in the OP to run startup scripts, didn't work so i moved on to sfhub tool.. i'm on aosp rom, does that matter?
must have mucked something up.. everything was running so smoothly too just i'm too OCD to not get this working.. might have to wipe..
Samsung Epic 4G Touch (E4GT)

"if i'm too drunk to walk, i rock a party on crutches"
 
kobridge
Old
#36  
kobridge's Avatar
Senior Member - OP
Thanks Meter 3458
Posts: 1,704
Join Date: Jan 2012
Location: Jacksonville, FL

 
DONATE TO ME
Quote:
Originally Posted by gershee View Post
OK. used your zip. extracted file. put in /system/etc/init.d and changed permissions to 755. rebooted. same thing..:what:
think I'm gonna wipe and start fresh. I dunna. I'm in codename with fd19 kernel.
here's screenies..



its weird. even when I delete the file in root explorer, if I refresh the directory it pops up with 0kb immedietly.. wth is going on..

---------- Post added at 05:09 PM ---------- Previous post was at 05:07 PM ----------



ahhhhh!
just looked in /etc/init.d (not /system) and i found the file also!!
i must have tried doing this last night before bed!!
deleted the file and rebooting now..

EDIT:
nope same thing. guess the system/etc/init.d files are copied to /etc/init.d on boot..
OK. Let me give you the last tweak on your 0test file. Open this file using root explorer text editor.
Pleace the cursor on every end of line. If there is a space between the last character of the line and cursor, remove the space between the last character and cursor (using backspace key). Move forward until last line and do the same thing. I believe this is simply the CR code inserted into your script.
Save the script and you will see the file size 108 Byte. Be sure that you remove the 0test.bak file from /system/etc/init.d directory.

************************************************
Samsung Galaxy Note 3 SM-N900V
Samsung Galaxy II EPIC 4G Touch SPH-D710
Kobridge's Stock GB27/GB08/GA10/FL16 ROM + Addons
Kobridge Tweak Pack v4.34
TD's GB27/GB08 AIO Mod for E4GT Jelly Bean
************************************************

 
sfhub
Old
#37  
Recognized Contributor
Thanks Meter 6830
Posts: 4,757
Join Date: Oct 2008
Quote:
Originally Posted by gershee View Post
1st, yes same timestamp. 22 apr 12 14:59:00
2nd, yes this makes sense.. i though it was something like this, i was just hoping i found the mistake i must have made..
3rd, at first i tried using the new script in the OP to run startup scripts, didn't work so i moved on to sfhub tool.. i'm on aosp rom, does that matter?
must have mucked something up.. everything was running so smoothly too just i'm too OCD to not get this working.. might have to wipe..
Is your AOSP using a repacked kernel or the stock kernel?

If the former, or you don't know, could you post the /init.rc file?
Disclaimer: No touchscreens were harmed nor injured during the creation of this post. GPS units were all treated ethically and humanely.
Signed: People against misbehaving Nexus 7 2013s
 
gershee
Old
#38  
gershee's Avatar
Senior Member
Thanks Meter 584
Posts: 1,531
Join Date: Oct 2006
Location: Miami, Florida
Quote:
Originally Posted by sfhub View Post
---------- Post added at 09:16 PM ---------- Previous post was at 09:12 PM ----------

[/COLOR]BTW I think it is worth looking into why the file keeps reappearing. It could give some clues what is going on.

Is it possible both SManager and init.d are trying to run the same script and they are stomping on each other?
i looked through smanager and tried to check make sure everything was disabled.. and i uninstallled it.. still nothing..
so weird.. something is fubar..
weird time stamp. constantly being created..
i dunna.. maybe have to wipe..
some small little mistake is screwing this up.. like stuck in a loop halfway through the script.. but where.. wtf!!
guess it doesn't matter.. ill just wipe when my gf leaves and i have some time.. frustrating when i can't stomp out this little biznatch problem...

---------- Post added at 05:26 PM ---------- Previous post was at 05:24 PM ----------

Quote:
Originally Posted by kobridge View Post
OK. Let me give you the last tweak on your 0test file. Open this file using root explorer text editor.
Pleace the cursor on every end of line. If there is a space between the last character of the line and cursor, remove the space between the last character and cursor (using backspace key). Move forward until last line and do the same thing. I believe this is simply the CR code inserted into your script.
Save the script and you will see the file size 108 Byte. Be sure that you remove the 0test.bak file from /system/etc/init.d directory.
i checked, it's 108Bytes, directly from your zip. just moved and changed permissions..

Quote:
Originally Posted by sfhub View Post
Is your AOSP using a repacked kernel or the stock kernel?

If the former, or you don't know, could you post the /init.rc file?
stock kernel. fd19, modified for aosp of course.. the one that came baked in..

it seems like somewhere early early on i messed up and something is looping recreating the same 0byte file. something is screwed..

---------- Post added at 05:30 PM ---------- Previous post was at 05:26 PM ----------

think i've wasted enough of both of you kind sirs time.
obviously it's a bug on my end and something small and clearly overlookable..
i'll just wipe this bad boy when i get a chance and start over i guess.. :/
Samsung Epic 4G Touch (E4GT)

"if i'm too drunk to walk, i rock a party on crutches"
 
kobridge
Old
#39  
kobridge's Avatar
Senior Member - OP
Thanks Meter 3458
Posts: 1,704
Join Date: Jan 2012
Location: Jacksonville, FL

 
DONATE TO ME
What's the permission of your init.d directory? Is it same 755?

************************************************
Samsung Galaxy Note 3 SM-N900V
Samsung Galaxy II EPIC 4G Touch SPH-D710
Kobridge's Stock GB27/GB08/GA10/FL16 ROM + Addons
Kobridge Tweak Pack v4.34
TD's GB27/GB08 AIO Mod for E4GT Jelly Bean
************************************************

 
gershee
Old
#40  
gershee's Avatar
Senior Member
Thanks Meter 584
Posts: 1,531
Join Date: Oct 2006
Location: Miami, Florida
Quote:
Originally Posted by kobridge View Post
What's the permission of your init.d directory? Is it same 755?
755
rwxr-xr-x
Samsung Epic 4G Touch (E4GT)

"if i'm too drunk to walk, i rock a party on crutches"

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes