[Q] Help with executing script? - Android Q&A, Help & Troubleshooting

I'm trying to get a script to execute via init.d or even in the terminal ... sh ./script but am running into issues that I'm not sure why or what is happening. I can't get the script to even execute via command line with the terminal app...so I need to figure that out first then maybe init.d will work. I can however execute the command in the script just fine, so I am not sure what is going on. It should be a simple script that I've seen posted on XDA. I started a thread over on the blaze dev section buy have been told it would fit here better so I'm posting a link to what I've already done.
http://forum.xda-developers.com/showthread.php?p=45042841#post45042841
As you can see from that link and the screenshot the execution of the script fails but I can echo that string in just fine. I'd like to get this scripted to it will work on boot and hopefully find a way to make it run before apps start starting so the sd card will prepare faster and the files I have apps linked to will be present when there requested...which is a problem.
Thanks!

Related

[Q] "Operation not permitted" trying to mount extSD as intSD

Hi, I've been trying to move all my game data from my internal SD card to my larger external SD card with no joy.
I have used condi's AIO tool to install init.d support, which reported as successful, but when I follow obicom's instructions as listed in POST #43 of this thread http://forum.xda-developers.com/showthread.php?t=1490116&page=5
I repeatedly receive the message "Operation not permitted."
I have used both ADB Shell and Terminal Emulator with the same result.
I'm obviously doing something wrong as other people appear to have had success with these instructions, I just don't know what.
Here's what I've done: (on rooted ICS from condi's AIO tool)
Installed init'd support "successfully"
Moved all data from sdcard/Android/data over to sdcard2/game_data
In ADB Shell/Terminal Emu. entered the following line;
mount -o bind /sdcard2/game_data /sdcard/Android/data
and this is where I get the "Operation not permitted" message.
Any ideas?
Once you're in shell, before running the mount command, run the command 'su' first (without the quotes). Your prompt should change from $ to # and try running the mount command again.
Explained: In most Linux systems, unless the fstab has been specifically setup to do it with the user option, filesystems can only be mounted by root. In rooted versions of Android, the normal user can elevate into a root prompt with su, then allowing you to mount and unmount any filesystems.
Ahaaa
Awesome! Can't believe it was something so simple, thanks, and thanks for explaining the reason.
I must have somehow totally missed the "su" instruction in the other thread.
Half of my games work, the other just seem to need re-installing which is no big drama.
Again, thanks, it's much appreciated mate.
Script?
agc93 said:
Once you're in shell, before running the mount command, run the command 'su' first (without the quotes). Your prompt should change from $ to # and try running the mount command again.
Explained: In most Linux systems, unless the fstab has been specifically setup to do it with the user option, filesystems can only be mounted by root. In rooted versions of Android, the normal user can elevate into a root prompt with su, then allowing you to mount and unmount any filesystems.
Click to expand...
Click to collapse
Hi, is there a way I can create a script (or the like) that would do this, and other similar directory changes, at boot?
At present I need to enter these manually each time the tablet starts, which isn't too much of a drama for me but when other people use it they end up downloading the data all over again when they start a game.
Thanks
There is an app available on Google Play called Script Manager (which can be used to create scripts to run at boot as su (which mount command require), which should do what you need. You'll need to use a plain text editor (I believe there is one included with Script Manager) to enter each of the mount command you want to run on a separate line. Then set the file to executable (chmod +x scriptname), and add it to Script Manager.
Note that I haven't used it in a while, so follow whatever instructions Script Manager gives you. They're probably more up to date.
agc93 said:
There is an app available on Google Play called Script Manager (which can be used to create scripts to run at boot as su (which mount command require), which should do what you need. You'll need to use a plain text editor (I believe there is one included with Script Manager) to enter each of the mount command you want to run on a separate line. Then set the file to executable (chmod +x scriptname), and add it to Script Manager.
Note that I haven't used it in a while, so follow whatever instructions Script Manager gives you. They're probably more up to date.
Click to expand...
Click to collapse
Okay thanks, yet again, I'll give it a try today.
Operation not permitted
Hi,i wanted to change my mac address on phone and even with that su command i get "operation not permitted" (my phone is rooted)...even apk named overclock for android could not grant root acces...in root checker my phone is rooted(and i have been rerooting it but still same).AND THERE IS NO FIX ON INTERNET

[Q] My Nabi 2 wifi isnt working please help fellahs!

hey everyone long story short i rooted my tablet a while back and started having problems so i flashed a new rom and the wifi isnt working.
I went to androidfiles.org and clicked nabi 2 and download wifi-fix, ota update and stock zip rom and flashed those three zip files ( i compressed them) in twrp.. its booting up and everything but wifi isnt working. ive read a lot of peeps are having wifi probs. I have a xda link for my exact device and you guys tell me wut the hell im supposed to do. its got all kinds of stock roms and ota updats and stuff,... which one do i use wtf do i do. should i go one at a time from lowest to biggest, do i even need ota updates or w./e that is?!?!?!? please help guys my chirstmas is becoming a nightmare... its my only internet source.. i had to come all the way to the dang library for this crap.. please help!!!!! heres the link that might give u guys an idea on how to help.. heres the stock roms and stuff
http://forum.xda-developers.com/wiki/Fuhu_nabi_2 thank you!!!!!
duuude im baked said:
hey everyone long story short i rooted my tablet a while back and started having problems so i flashed a new rom and the wifi isnt working.
I went to androidfiles.org and clicked nabi 2 and download wifi-fix, ota update and stock zip rom and flashed those three zip files ( i compressed them) in twrp.. its booting up and everything but wifi isnt working. ive read a lot of peeps are having wifi probs. I have a xda link for my exact device and you guys tell me wut the hell im supposed to do. its got all kinds of stock roms and ota updats and stuff,... which one do i use wtf do i do. should i go one at a time from lowest to biggest, do i even need ota updates or w./e that is?!?!?!? please help guys my chirstmas is becoming a nightmare... its my only internet source.. i had to come all the way to the dang library for this crap.. please help!!!!! heres the link that might give u guys an idea on how to help.. heres the stock roms and stuff
http://forum.xda-developers.com/wiki/Fuhu_nabi_2 thank you!!!!!
Click to expand...
Click to collapse
Thought I would share some info I found when I ran into the wifi problem on my daughter's nabi. I did some searches on the internet and the typical answer I found for solving the wifi issue was "reset the device" or "unroot and return to stock rom - flash all updates and reroot". Being a glutton for punishment, and the fact I didn't want to reset the device, I searched and searched and was able to fix my daughter's wifi without doing a reset or unroot/reroot. Before I get into it I wanted to mention that wifi failures can happen for a number of reasons so while this worked for myself, it may not work for you.
Some prerequisites:
Most importantly; you need a rooted device. If you do not have root access you will not be able to write files or access the commands to fix the issue I am about to outline.
Some knowledge of linux would be helpful, but not necessarily required.
Lets get started:
Warning! It goes without saying but I will say it anyways - you can mess up your nabi by rooting it. Some of the commands below could mess up your nabi bad. If this scares you then you probably should not proceed any further. I am not responsible for any damage you do to your nabi.
Commands are listed between ' and ' - do not use the ' when inputing the commands.
Note: The first two/three steps are not necessary but they do give you insight as to how I was able to determine my problem. If following this doesn't fix the problem for you the logcat output may give you some important info that you can google that may help you fix your particular problem.
Note: Steps 5 and on can be skipped if you have a text editor (vi or nano) on your device. If you have a text editor loaded simply edit the conf file directly.
1. You will need to run the command 'adb logcat' in a command-line window and in your appropriate directory. Adb is available as part of the android sdk but can also be found stand alone since most people do not need the sdk.
2. Try to turn on the wifi. You should see the output of your adb logcat window scroll some data. If the wifi is not attempting to turn on at all sometimes you can move between the settings options then go back to the wifi settings and move the slider. If you cannot get your wifi to turn on you can scroll the window up and attmept to find the data from when the device started up. In the output you should see lines that talk about wlan0 and probably something that says "failed" somewhere. In my case I could see where the wlan0 enabled but then a few lines down it said something about "Line: 25 failed" and "failed to parse file".
3. The file is actually a configuration file used by the wifi kernal module/driver. In my case this file had become corrupted.
4. Set adb in root mode (won't work if the device does not have root access) by running 'adb root' at the command-line. You may need to click on an "allow root permission" window on the actual device after running this command.
5. Run 'adb pull /data/misc/wifi/wpa_supplicant.conf' from command-line. If this does not work then do the following:
a. Run 'adb shell' from command line.
b. 'su'
c. 'cat /data/misc/wifi/wpa_supplicant.conf' - copy the output from the command and paste into a text editor (see note in step 6 on why NOT to use notepad).
d. Save the file as wpa_supplicant.conf, preferrably in the same diretory as adb.
e. 'exit' twice should exit you from the adb shell and return you to your command-line. If all else failes a "ctrl-c" should drop you out of adb.
6. Use a text editor to open wpa_supplicant.conf. The file should be located int he same directory as adb. If you are using Windows I would strongly suggest you NOT use notepad. Notepad will typically change all the EOLs (End Of Line) from \n to \r\n which will really mess things up worse.
7. In the file you should see "network={" entries. There maybe one entry, there maybe many entries. You can remove all lines between "network={" and "}" including the latter themselves. If you see your 'home' network listed you can leave it as the only entry and make sure its priority is set to 1 but it maybe better to remove it as well just in case it contains part of the corrupted data.
8. Save the file.
9. Do 'adb push wpa_supplicant.conf /data/misc/wifi/wpa_supplicant.conf' from command-line. If this does not work then do the following:
a. Run 'adb push wpa_supplicant.conf /sdcard/wpa_supplicant.conf' from command-line.
b. Run 'adb shell'
c. 'su'
d. 'dd if=/sdcard/wpa_supplicant.conf of=/data/misc/wifi/wpa_supplicant.conf'
e. Do 'exit' twice to exit the adb shell. If all else fails then a "ctrl-c" should drop you ot of adb.
10. If the wpa_supplicant file was corrupted then the wifi should now be able to enable and you should now be able to connect to a network.
I hope this is helpful to at least a few people.

[Q] Commands that work in terminal, but not when put in script

Hi everyone,
I am having a general conundrum that is really setting me back. My device(s) are my HTC One (rooted) and and CS968 (rooted) mini-pc. I've tried the following on both devices and always get the same thing. I don't think its device specific:
I am trying to install an APK. When I go into Terminal Emulator and get su permissions, I type in the following command "pm install /sdcard/directory/of/apk/target.apk" and it works, success, the apk is installed.
If I write a .sh script with the EXACT same syntax, I always get the infamous "INSTALL_FAILED_INVALID_URI" error. I cannot for the life of me figure out why.
Yes, I have searched every corner of this forum and google for solutions to this problem. They all end with the conclusion that you need to re-flash your rom (???) which seems very improbable to me. What makes my case different is that, like I said, the command works just fine when manually entered into Terminal Emulator, but when executed from a script, is when I get this bizzare error. I am at my wits end.
If anyone could shine some light on this for me I would greatly appreciate it.
Thank you

init.rc to launch a script at boot

I'm trying to get a script to launch. I've done quite a bit of research; nothing I've found has proved very useful. I'm trying to do this on a Galaxy S3 with Cyanogenmod 10.2 Stable. Since it looks like this is a neglected issue on XDA, I'll also reference the other posts which I've read.
Running it as root at startup with SManager works, but I would really prefer to bypass a 3rd-party app.
My script doesn't seem to be loading at boot; it should create a PID file in my /sdcard folder, but it doesn't. Without knowing the PID, I have no way of verifying whether or not it's even running.
Code:
#!/system/bin/sh
(while [it's a never-ending loop]...do [stuff]; busybox sleep 900s...done) & echo $! > /sdcard/myscript.pid &
I've tried a couple different ways of calling this script from init.rc:
Code:
on boot
sh /system/bin/myscript.sh
and
Code:
service myscript(*I also tried "myscript_boot") /system/bin/myscript.sh
user root (*also tried it without the user command)
oneshot (*and without oneshot)
I also find it strange that my changes to init.rc are persistent after reboot since many, many articles suggest that it should be reset after reboot (I've noticed that many of these articles date back to ~2010).
Since I can't find any conclusive documentation on this issue. I hope someone here can shed some insight.
# Editing init.rc
http://forum.xda-developers.com/showthread.php?t=2069928
# Tried following this article to edit/flash the boot image, but I don't have "/proc/mtd"
http://droidcore.blogspot.com/2012/12/how-to-edit-initrc-in-android.html
# A neglected post very similar to mine
http://forum.xda-developers.com/showthread.php?t=1894607
# Another neglected post which addresses this issue
http://forum.xda-developers.com/xperia-u/issues/xperia-cm9-unable-to-launch-script-init-t2089749
One more thing. My script runs fine if I issue the command in the Terminal emulator, adb shell, and, as mentioned earlier, if launched with SManager. It's only init.rc that's giving me issues.

How to get command rsync?

Hi,
I should want to use rsync to copy new and modified files (and only these ones) on an USB key but it's not in my Androïd version even if I have an AICP rom which uses Cyanogenmod 12 (I've red rsync is in Cyanogenmod). I use this command on a Linux box in a .sh script and it's convenient. I would do the same thing on my phone with using SManager if it's possible.
I've looked for this command for Androïd but a search only returns Rsync Backup which is not anymore on Google Play. It's an application, I don't know if I can get a command to use it in a script. I've also done searches on the forum and if I could see guys use it, I haven't found how they get it.
Does somebody knows how to get it?
Thank you .
I've found a binary command :
http://ptspts.blogspot.fr/2015/03/how-to-use-rsync-over-adb-on-android.html
It's necessary to install it in a system directory otherwise I can't give it execute permissions. I put it in /system/bin

Categories

Resources