Busybox ash - execution with permission denied [duplicate] - android

This question already has an answer here:
Android: Executing a program on adb shell
(1 answer)
Closed 4 years ago.
I'm trying to run busybox on an Android device, I pushed busybox binary to /tmp folder, then add a i.sh file in /tmp folder with code below:
#!/bin/sh
echo aa
/tmp/busybox dirname
Then enter /tmp folder and execute like this: ./busybox ash ./i.sh
Error report:
./i.sh: line 3: /tmp/busybox: Permission denied
Device is rooted, setenforce has set to 0.
If use system sh to execute this file sh ./i.sh, everything is ok.

If you don't have root access in your Android you can copy busybox into the path "/data/local/tmp" and run it like "/data/local/tmp/./busybox"

Related

shell script to get file from android sdcard with adb shell [duplicate]

This question already has answers here:
Copy a batch of files from Android to PC
(2 answers)
Closed 4 years ago.
#!/bin/bash
DIR_PATH="/sdcard/log/xxxxdir"
function useAdbReadLastFileFromDir(){
fileName=`adb shell ls $1|tail -1`
if [ -n $fileName ]
then
echo "fileName:"
echo "adb pull $PATH/$fileName"
fileContent=`adb pull $PATH/$fileName`
echo "fileContent:"$fileContent
else
echo "file not found exception"
fi
}
useAdbReadLastFileFromDir $DIR_PATH
android6.0 yotaphone/sunsang note5 can't pull file from sdcard, error message said:
file or dir not exist
but androi8.0 oppo findx/mi mix2 does.
help~!
adb pull takes 2 mandatory parameters: REMOTE_FILENAME and LOCAL_FILENAME
If you want to adb pull a text file to stdout - use adb shell cat FILENAME instead

adb REMOTE pull file to desktop [duplicate]

This question already has answers here:
Android: adb pull file on desktop
(6 answers)
Closed 4 years ago.
Android: adb pull file on desktop
Trying to copy file from remote device to desktop, here is a command:
adb -s xx.xx.xx.xx:5555 pull sdcard/screen.png c:/users/xx/desktop/
But I always get the message:
cannot create 'c:\users\xx\desktop\': No such file or directory!! | in sdcard
if i run the same command whitout dir path
adb pull <remote> [local]
adb -s xx.xx.xx.xx:5555 pull sdcard/log.txt log1.txt
it well copy file screen.png to the same android sdcard dir not sdk folder in my windows Os
do adb has the ability to transfer file over tcp/ip like the documentation (adb pull <remote> [local]) or im wrong ??
If I am not wrong, "/" is for defining path in Unix systems. Try to use "\" as Windows systems define path.

adb shell command from batch file [duplicate]

This question already has an answer here:
windows batch script not execute next line after "adb shell"
(1 answer)
Closed 5 years ago.
I have a .bat file that runs script for testing an app and printing the log to file i have all the commands i tested them manually.
Problem:
after entering the command adb shell, the shell opens in the command prompt. I wrote the next commands that are entered in the shell with root#generic
the commands aren't going through and it just waits at that spot.
what do i have to type in front of the commands to make them appear
example of what i have
cd directory of sdk
adb
adb shell
am instrumentation ... (this is the command that won't go through once the shell is open.
any help appreciated I've tried a few things with no success
Just use the following line in your batch file:
adb shell am instrumentation
that will connect to the shell on the Android device and run the am command.

script running through too fast! possibly

I have been attempting to write a script to harden android. I have had no success!
I am running a AVD via emulator and have tried this with both the android shell and bash shell which i loaded. The script is simple as you will see below and each command runs fine independently but in a script it just runs through too fast or something.
I know there's no shebang at the top but that's because of errors when i inserted one.
my script is:
echo ANDROID
echo HARDENING STARTED
device=/dev/block/mtdblock0
mount -o rw,remount $device /system
#removing files in the /system/xbin directory
rm /system/xbin/tcpdump
rm /system/xbin/su
#removing files in the /system/bin directory
rm /system/bin/bootanimation
rm /system/bin/dumpstate
rm /system/bin/ping
rm /system/bin/ping6
echo ANDROID
echo HARDENING COMPLETE
I have taken all indenting out as i thought this may be causing the error and the directories and files definitely exist. I have been on this for three days now and its wearing thin.
I had an if statement at the beginning to select devices on other handsets but i took this out in attempt to reduce errors (that's why i declare device instead of mounting).
here is the error:
ANDROID
HARDENING STARTED
mount: no such file or directory exist
, no such file or directorytcpdump
, no such file or directorysu
, no such file or directoryootanimation
, no such file or directoryumpstate
, no such file or directorying
, no such file or directorying6
ANDROID
HARDENING COMPLETED
NOTICE THE MERGING AFTER DIRECTORY THIS IS NOT A TYPO.
thanks Ryan
You edited this file on a Windows system and it has DOS-style end-of-lines (<cr><lf>). Convert it to use Unix-style end-of-line markers (<lf>) and it should work fine. Any decent programmer's editor will have the ability to do this for you, or you can do it using standard command line tools.
Incidentally, the shell doesn't care about indenting at all. This:
echo Hello
echo world.
Is the same as:
echo Hello
echo world.
Change the line ending to Unix style, will solve all your problem.

Failed to push to SD card [duplicate]

This question already has answers here:
Android+Eclipse: Can't push files to SD Card [duplicate]
(7 answers)
Closed 9 years ago.
I am using windows vista on which I installed android. I created an sd card file(.img extension). When I tried to push a file to it through ddms, it showed that 'Failed to push' . Also I could see that the permission parameter was set as d-----. How to reslove this issue. Thanks in advance
Once you started the Emulator from one shell, login to another shell & type
adb shell
You should see # prompt displayed, this is your device(emulator) shell. Now , type following command at adb shell.
mount -o remount rw /sdcard
This will now remount /sdcard with rw(read-write) permission & now you can push your files into /sdcard by using following command from your host shell.
adb push filename.mp3 /sdcard, where filename.mp3 could be any file that you want to push into Android Emulator.

Categories

Resources