Related
Hi,
I'm making a batch file (*.bat) for myself to try make some things easier file where I enter commands with adb.exe.
The problem is, any code after 'adb shell' is not executed in the batch.
So if I had a batch with the following:
Code:
adb shell
su
'su' will not be executed and stays at '$'.
It seems like it's too deep for a batch file to enter codes.
I also tried pushing a sh with the same script and run it from adb but then all I get it permission denied.
I have also tried 'adb shell su' without any luck.
Anyone with a solution?
Anyone? Or how about a .rc file that gets su and runs commands...
Sent from my HTC
To execute a script, you can always push your script and then execute it:
Code:
adb push script /sdcard/script
adb shell sh /sdcard/script
As for the commands you have shown, keep in mind that su doesn't simply change the running shell's permissions or the like but creates a new child environment within its own shell. You leave your script and after the new shell has finished, you're back in your old environment and the script continues.
mizch said:
To execute a script, you can always push your script and then execute it:
Code:
adb push script /sdcard/script
adb shell sh /sdcard/script
As for the commands you have shown, keep in mind that su doesn't simply change the running shell's permissions or the like but creates a new child environment within its own shell. You leave your script and after the new shell has finished, you're back in your old environment and the script continues.
Click to expand...
Click to collapse
yes, is there any way to automate the script inside the shell and use exit to finally go back to the batch script.
Can you provide me with an example of what you want to achieve?
To execute shell commands from a batch, it doesn't matter if I have to push a script and execute it. It's so that I get su and automate commands after that. Like flash_image, remount, chmod etc..
you will need to use the 'adb shell command' ad 'sh' files
I am trying to create a unix script file that copies files from /dbdata/databases to another folder as a backup.
When I try running the script in adb shell as SU, I get
cd: can't cd to /dbdata/databases
This is on a rooted Captivate. Any help would be greatly appreciated!
Hi,
su -c "command" should do the job for you. You will need to enclose the whole of the command in quotes however, otherwise su will be expecting the command to execute, doing nothing.
Example: adb shell "su -c 'sqlite3 /data/data/my.db/databases/mydb.db < /sdcard/dump.sql'" (run from a Unix or Windows(?) shell). Notice the use of "" and ''.
(in this case dump.sql contains .dump, for instance)
Of course the sqlite3 command could be placed within another script on the android device.
Hope that helps.
I looked around a bit and found the answer.
The simple answer is, wrap the command
Code:
cp "source" "destination"
in double quotes!
Thank you grindingbob for the adb shell "su -c 'sh /mnt/sdcard/tmp/2.sh'" command.
No probs I was more referring to executing commands as a su without interacting with adb shell.
As a side-note, cp might not be a good idea, unless you're sure no db accessing is taking place at the same time.
I am pretty sure well as sure as a novice can be! The files I am backing up are log files, call history and text message history.
The results from running a unix script which contains
Code:
cp "/dbdata/databases/com.android.providers.contacts/contacts2.db" "/mnt/sdcard/tmp4/contacts2.db"
cp "/dbdata/databases/com.android.providers.telephony/mmssms.db" "/mnt/sdcard/tmp4/mmssms.db"
cp "/dbdata/databases/com.sec.android.provider.logsprovider/logs.db" "/mnt/sdcard/tmp4/logs.db"
are only the logs.db file is copied, the other two are not.
grindingbob said:
No probs I was more referring to executing commands as a su without interacting with adb shell.
As a side-note, cp might not be a good idea, unless you're sure no db accessing is taking place at the same time.
Click to expand...
Click to collapse
Permission issues for *.sh files from ADB
Dear All,
I have a 3.2 device with Root permissions & Busybox.
I created a sample *.sh file, Pushed to SDcard, and gave '777' Permissions. When i Try to run it from ADB shell its not working Any help...
CMD prompt Traces:
Step -1: Created a sh file
cat TAB.sh
#!/bin/sh
cd /data/data/com.android.gallery/shared_prefs
Step -2 Pushed the file to SDcard
# ls -l *.sh
ls -l *.sh
-rw-rw-r-- root sdcard_rw 56 2012-03-13 15:06 SP.sh
-rw-rw-r-- root sdcard_rw 62 2012-03-13 15:05 TAB.sh
Step -3 Gave 777 permission for *.sh files
# chmod 777 *.sh
chmod 777 *.sh
# ls -l
ls -l
-rw-rw-r-- root sdcard_rw 56 2012-03-13 15:06 SP.sh
-rw-rw-r-- root sdcard_rw 62 2012-03-13 15:05 TAB.sh
Execute permission not applied
Tried other operations, dint workout
Step 4 other options:
# chmod +X *.sh
chmod +X *.sh
Bad mode
# chmod +x *.sh
chmod +x *.sh
Bad mode
# chmod u+x *.sh
chmod u+x *.sh
Bad mode
Any Help?
I am using a rooted HTC G2 with Clockwork recovery and Cyanogenmod 6.1.1.
I broke my launcher, ADW EX, using Ninjamorph; the phone now gets stuck on the boot animation.
My planned solution was to use adb install to restore a backup of ADW EX.
Using adb pull I pulled a backup of ADW EX and placed in C:\
I mounted /system and /data in recovery
Using adb from recovery I entered adb shell and removed the broken ADW EX with:
rm /data/app/org.adwfreak.launcher-2.apk
Next, I exited adb shell and entered:
adb install C:\org.adwfreak.launcher-2.apk
This generated the error:
/sbin/sh: pm: not found
I cannot get past this error and successfully install the application. I am learning as I go, any direction or assistance is welcome. I miss my Android
Solved
In case any other doofus' run into this situation.
As I have now learned, the "adb install" command will not work from recovery.
Because I had broken my launcher, and I had no alternative launchers installed, there was no launcher to hand-off to after booting; the result was an endless boot animation. Calls and notifications could still be received, etc. Most importantly, the phone was no longer in recovery and "adb install" could be used.
adb install C:\org.adwfreak.launcher-2.apk
Press "home"
Fixed.
hi,
in adb shell type:
cd /system/bin
cp pm ap_process /sbin/
exit
and now try again to install/uninstall the app.
hosseinb said:
hi,
in adb shell type:
cd /system/bin
cp pm ap_process /sbin/
exit
and now try again to install/uninstall the app.
Click to expand...
Click to collapse
I am getting error at second command
/system/bin >> cp pm ap_process /sbin/
cp pm ap_process /sbin/
cp: can't stat 'pm': No such file or directory
cp: can't stat 'ap_process': No such file or directory
can you tell why
nialexme said:
I am getting error at second command
/system/bin >> cp pm ap_process /sbin/
cp pm ap_process /sbin/
cp: can't stat 'pm': No such file or directory
cp: can't stat 'ap_process': No such file or directory
can you tell why
Click to expand...
Click to collapse
Sorry for my delay;
It's because the files (pm & ap_process) do not exist in /system/bin , try to locate them by "find" command:
adb shell
#find / -name ap_process
good luck
~ # find / -name ap_process
find: /sys/kernel/slab/L2TP/IP: No such file or directory
~ # exit
and now ?!!
kb667 said:
~ # find / -name ap_process
find: /sys/kernel/slab/L2TP/IP: No such file or directory
~ # exit
and now ?!!
Click to expand...
Click to collapse
Do you have root access? Have you installed busybox?
I am trying to make a simple shell script and I am getting constant errors.
So i made a test.sh file and saved it in /data because /sdcard is excuetable protected.
The shell file contains:
#!/system/bin/sh
cd /sdcard
mkdir test
echo Done!
So then I typed the command chmod 777 /data/test.sh
And then /data/test.sh and it returned: tmp-mksh: /data/test.sh: No such file or directory
So then I tried running: sh /data/test.sh and it returned:
No such file or directoryrd
Done
skyguy126 said:
I am trying to make a simple shell script and I am getting constant errors.
So i made a test.sh file and saved it in /data because /sdcard is excuetable protected.
The shell file contains:
#!/system/bin/sh
cd /sdcard
mkdir test
echo Done!
So then I typed the command chmod 777 /data/test.sh
And then /data/test.sh and it returned: tmp-mksh: /data/test.sh: No such file or directory
So then I tried running: sh /data/test.sh and it returned:
No such file or directoryrd
Done
Click to expand...
Click to collapse
I'm not an expert on this, could be an issue with the proper access rights.
Here is a thread about a similar issue with shell scripting: Android Development and Hacking Android Software Development sl4a shell script help.
Maybe this can help already.
And here is a general guide for using shel scripts: [GUIDE] Basic Unix/Linux command to use with ADB SHELL
If you have further questions about this topic, best to post in the Android Development and Hacking > Android Q&A, Help & Troubleshooting forum.
Thread closed and thank you.
Quick guide for people having trouble rooting/unlocking bootloader and custom recovery LG-D320/N/L70 devices running 4.4.2 with a new 3.4.0+ kernel
This way is easier then any root method and NO PC is required
Simple, straight forward, takes not even 5 minutes.
First download and install these 3 apps.
CPU Benchamark
Terminal Emulator
KingoRoot.apk
Second, download this zip file and extract the "mrw" folder to your phones internal memory(/sdcard)
ReplaceKingoRoot.zip
Third, open CPU Benchtest app and press the "stress test" box, then minimize the app and open Kingo ROOT app and press the "ROOT" bubble
Fourth, Kingo ROOT says your device is rooted open Terminal Emulator and type the following
Code:
su
Your device will ask if Terminal Emulator can be granted root permissions, allow it then proceed to type the following
Code:
sh /sdcard/mrw/root.sh
Then SuperSU will automatically open and ask to update SuperSU binaries, select the "update" box and when it asks you how you want to update it select the "normal" box
Five, Restart your phone when SuperSU says you need to restart for the update to take effect
Now, unlocking the bootloader and flashing a custom recovery, fortunately i made a tool for this with the required files.
simply download this, unzip it onto the desktop and run LGTOOL.BAT by double clicking it and follow the instructions.
LG TOOL BY RICKY DIVJAKOVSKI
ENJOY GUYS
Credits:
jeffta74
wanako1
MrW0lf
updated.
I'm AndroidAddict aka MikeHoncho at AF btw. Glad to see someone post something even though we never got a forum here
AndroidAddict||AA said:
I'm AndroidAddict aka MikeHoncho at AF btw. Glad to see someone post something even though we never got a forum here
Click to expand...
Click to collapse
every device should be able to gain full flexibillity, no matter how old, how new, how popular or unpopular and device i get my hands on will gain full access
time to make a custom rom now
I think everything is done "custom ROM" wise. AOSP, cm11, cm12, carbon (by me) and other ROMs
AndroidAddict||AA said:
I think everything is done "custom ROM" wise. AOSP, cm11, cm12, carbon (by me) and other ROMs
Click to expand...
Click to collapse
ofcoarse its done custom rom wise, you can modify a rom with root access but to safely modify a rom and test recovery is mandatory
Terminal emulator not working
Thx for this guide.
terminal emulator can't install SuperSU.
Here's the log, whats wrong?
Tried also to install supersu manually, but can't update it so is absolutely useless.
[email protected]:/ $ su
l_SD/ReplaceKingoRoot/mrw/root.sh <
---------------------------------------
---------- Made By : Mr.W0lf ----------
---- Thanks @Chainfire for SuperSU ----
---------------------------------------
---------------------------------------
----- UPDATED BY RICKY DIVJAKOVSKI ----
---------------------------------------
Failure
Failure
rm failed for /system/app/KingoUser, No such file or directory
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[20]: cat: sdcard/mrw/busybox: No such file or directory
rm failed for /system/xbin/ku.sud, No such file or directory
rm failed for /system/xbin/su, Operation not permitted
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[33]: can't create /system/xbin/su: Permission denied
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[34]: can't create /system/xbin/daemonsu: Text file busy
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[35]: cat: /sdcard/mrw/su: No such file or directory
Unable to chown /system/xbin/su: Operation not permitted
Unable to chmod /system/xbin/su: Operation not permitted
daemonsu: invalid option -- d
Usage: su [options] [--] [-] [LOGIN] [--] [args...]
Options:
--daemon start the su daemon agent
-c, --command COMMAND pass COMMAND to the invoked shell
-h, --help display this help message and exit
-, -l, --login pretend the shell to be a login shell
-m, -p,
--preserve-environment do not change environment variables
-s, --shell SHELL use SHELL instead of the default /system/bin/sh
-u display the multiuser mode and exit
-v, --version display version number and exit
-V display version code and exit,
this is used almost exclusively by Superuser.apk
rm failed for /data/data-lib/com.kingoapp.root, No such file or directory
rm failed for /data/data-lib/com.kingouser.com, No such file or directory
rm failed for /data/data/com.kingroot.RushRoot, No such file or directory
rm failed for /data/data-lib/com.kingroot.RushRoot, No such file or directory
rm failed for /data/data/com.kingroot.kinguser, No such file or directory
rm failed for /data/data-lib/com.kingroot.kinguser, No such file or directory
rm failed for /data/data/com.kingroot.master, No such file or directory
rm failed for /system/bin/.usr/.ku, No such file or directory
rm failed for /system/bin/rt.sh, No such file or directory
rm failed for /system/bin/su, Operation not permittedrm failed for /system/bin/ddexe, No such file or directory
rm failed for /system/bin/install-recovery.sh, No such file or directory
rm failed for /system/bin/install-recovery.sh-ku.bak, No such file or directory
pkg: /sdcard/mrw/superuser.apk
Failure [INSTALL_FAILED_INVALID_URI]
rm failed for /system/usr/iku, No such file or directory
rm failed for /dev/reportroot, No such file or directory
rm failed for /system/app/Kinguser, No such file or directory
rm failed for /data/data-lib/king, No such file or directory
rm failed for /sdcard/Kingroot, No such file or directory
Error type 3
Error: Activity class {eu.chainfire.supersu/eu.chainfire.supersu.MainActivity} does not exist.
[email protected]:/ #ll
Ggcost said:
Thx for this guide.
terminal emulator can't install SuperSU.
Here's the log, whats wrong?
Tried also to install supersu manually, but can't update it so is absolutely useless.
[email protected]:/ $ su
l_SD/ReplaceKingoRoot/mrw/root.sh <
---------------------------------------
---------- Made By : Mr.W0lf ----------
---- Thanks @Chainfire for SuperSU ----
---------------------------------------
---------------------------------------
----- UPDATED BY RICKY DIVJAKOVSKI ----
---------------------------------------
Failure
Failure
rm failed for /system/app/KingoUser, No such file or directory
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[20]: cat: sdcard/mrw/busybox: No such file or directory
rm failed for /system/xbin/ku.sud, No such file or directory
rm failed for /system/xbin/su, Operation not permitted
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[33]: can't create /system/xbin/su: Permission denied
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[34]: can't create /system/xbin/daemonsu: Text file busy
/storage/external_SD/ReplaceKingoRoot/mrw/root.sh[35]: cat: /sdcard/mrw/su: No such file or directory
Unable to chown /system/xbin/su: Operation not permitted
Unable to chmod /system/xbin/su: Operation not permitted
daemonsu: invalid option -- d
Usage: su [options] [--] [-] [LOGIN] [--] [args...]
Options:
--daemon start the su daemon agent
-c, --command COMMAND pass COMMAND to the invoked shell
-h, --help display this help message and exit
-, -l, --login pretend the shell to be a login shell
-m, -p,
--preserve-environment do not change environment variables
-s, --shell SHELL use SHELL instead of the default /system/bin/sh
-u display the multiuser mode and exit
-v, --version display version number and exit
-V display version code and exit,
this is used almost exclusively by Superuser.apk
rm failed for /data/data-lib/com.kingoapp.root, No such file or directory
rm failed for /data/data-lib/com.kingouser.com, No such file or directory
rm failed for /data/data/com.kingroot.RushRoot, No such file or directory
rm failed for /data/data-lib/com.kingroot.RushRoot, No such file or directory
rm failed for /data/data/com.kingroot.kinguser, No such file or directory
rm failed for /data/data-lib/com.kingroot.kinguser, No such file or directory
rm failed for /data/data/com.kingroot.master, No such file or directory
rm failed for /system/bin/.usr/.ku, No such file or directory
rm failed for /system/bin/rt.sh, No such file or directory
rm failed for /system/bin/su, Operation not permittedrm failed for /system/bin/ddexe, No such file or directory
rm failed for /system/bin/install-recovery.sh, No such file or directory
rm failed for /system/bin/install-recovery.sh-ku.bak, No such file or directory
pkg: /sdcard/mrw/superuser.apk
Failure [INSTALL_FAILED_INVALID_URI]
rm failed for /system/usr/iku, No such file or directory
rm failed for /dev/reportroot, No such file or directory
rm failed for /system/app/Kinguser, No such file or directory
rm failed for /data/data-lib/king, No such file or directory
rm failed for /sdcard/Kingroot, No such file or directory
Error type 3
Error: Activity class {eu.chainfire.supersu/eu.chainfire.supersu.MainActivity} does not exist.
[email protected]:/ #ll
Click to expand...
Click to collapse
Yea i have the same problem with this i've done everything right step by step but seems cant find the location of the root can anyone help me or the topic is dead ?
ok ive yet to have to ask any ? on xda yet cause i feel like i dont know jack lol
BUT i do need help wile trying to remember linuix commands for adb shell and trying to replace boot animation.zip ans learned the mv file file2 overwrite/rename (i must say i find sort of retarted,but i dont do this for a living) and relized i had remount system as rw i exit shell heres the super mistake please help b4 i have to restart from stock
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb remount
Using overlayfs for /vendor
Now reboot your device for settings to take effect
remount succeeded
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb reboot
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb devices
List of devices attached
ZY22CCHMQT recovery
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb shell
kiev:/ # cd system/media
cd system/media
/system/bin/sh: cd: /system/media: No such file or directory
2|kiev:/ # cd /system
cd /system
kiev:/system # cd /media
cd /media
/system/bin/sh: cd: /media: No such file or directory
2|kiev:/system # cd media
cd media
/system/bin/sh: cd: /system/media: No such file or directory
On stock, it is located at /system/product/media