Why do I keep getting this error?
>> gcc a.out
>> ./a.out
bash: ./a.out: Permission denied
I even tried this
>> chmod +x a.out
But still I keep getting the error. I have installed clang and termux-setup-storage package. My files are in main memory (not on sd card).
Termux has only problem executing a.out file. If I make any error in C program it fails to compile the a.c file
You can't execute executable in internel storage because that's mount with noexec in android.
Move that binary somewhere in termux home directory or $PREFIX.
so if you need to run those file than you need to run
$ ls //to see your file is here or not .if not than change directory
$ mv a.out ~
$cd ~
$chmod +x a.out
$./a.out
If you just installed termux api?
$ pkg install root-repo
Revoke termux app permission in settings.
$ termux-setup-storage
And taraa!!
Related
I am trying to unzip files in my android (11) phone with ADB from the terminal (Ubuntu 20.04). I need to run a script from my Ubuntu laptop to unzip files on my phone.
I have already tried Busybox from this suggestion. With this app, I can unzip files after accessing the shell. I mean -
$ adb shell
a60q:/ $ cd /sdcard/
a60q:/sdcard $ unzip data.zip
Archive: data.zip
inflating: Screenshot from 2020-11-30 16-45-46 (7th copy).png
inflating: Screenshot from 2020-11-30 16-45-46 (10th copy).png
But when I try to use the direct command, it shows an error.
$ adb shell unzip /sdcard/data.zip
unzip: couldn't create file Screenshot from 2020-11-30 16-45-46 (7th copy).png: Read-only file system
Archive: /sdcard/data.zip
Rooting phone isn't an option. My questions are -
What can I do here to unzip from the terminal?
Is there any tool to make compressed zip files (in Android) from the terminal?
In order to successfully invoke the unzip command from the terminal you should explicitly specify the folder where the zip's content will be extracted, for instance:
adb shell unzip /sdcard/data.zip -d /sdcard
By invoking unzip --help you will get more information on the other parameters available as well.
I have some trouble to run a docker android emulation from this project: https://github.com/thyrlian/AndroidSDK
Since I am a Linux (using Ubuntu 18) noob maybe I am just too stupid...
I'm failing with mounting the image to my container...in the tutorial its done with this command:
docker run -it --rm -v $(pwd)/sdk:/sdk thyrlian/android-sdk bash -c 'cp -a $ANDROID_HOME/. /sdk'
So i downloaded android-sdk-tools and extracted it into my root dir named "sdk". so my command looked like this:
docker run -it --rm -v sdk bash -c 'cp -a $ANDROID_HOME/. /sdk'
But than I got tons of errors (those are just a few since they are all similiar):
cp: can't open '/./sys/bus/isa/uevent': Permission denied
cp: can't open '/./sys/bus/isa/drivers_probe': Permission denied
cp: can't open '/./sys/bus/xen/uevent': Permission denied
cp: can't open '/./sys/bus/xen/drivers_probe': Permission denied
cp: can't open '/./sys/bus/serio/uevent': Permission denied
With python 3.6.4:
In a fresh Termux installation I do accordnung to https://wiki.termux.com/wiki/Arch
pkg install wget
wget https://raw.githubusercontent.com/sdrausty/TermuxArch/master/setupTermuxArch.sh
bash setupTermuxArch.sh
After that in ArchLinux:
$ pacman -S python python-pip
(success)
$ pip install simplejson (or any other package)
And always get:
running install_egg_info
running egg_info
writing simplejson.egg-info/PKG-INFO
writing dependency_links to simplejson.egg-info/dependency_links.txt
writing top-level names to simplejson.egg-info/top_level.txt
reading manifest file 'simplejson.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'simplejson.egg-info/SOURCES.txt'
Copying simplejson.egg-info to /root/.local/lib/python3.6/site-packages/simplejson-3.13.2-py3.6.egg-info
error: [Errno 13] Permission denied: '/root/.local/lib/python3.6/site-packages/simplejson-3.13.2-py3.6.egg-info/PKG-INFO'
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r_x__623/simplejson/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-4dfnzavt-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-r_x__623/simplejson/
Also --user or pyvenv don't help at all. Any suggestions, what am I doing wrong?
Please note:
Android device is not rooted
The ArchLinux user is root (default)
Permissions look good. I can copy files manually to the destination directory just ok.
UPDATE: With python 2.7.14 everything works well.
My same BASH script is working in Fedora/CentOS.
But I am testing one Android eee pad transformer.
Where i have terminal access and i wrote a small test script. But its not working, how can i fix it? what am i doing wrong?
/data/data/berserker.android.apps.sshdroid/home $ cat test.sh
#!/bin/bash
var=`ifconfig -a`;
echo $var;
/data/data/berserker.android.apps.sshdroid/home $ chmod +x test.sh
/data/data/berserker.android.apps.sshdroid/home $ ./test.sh
sh: ./test.sh: not found
/data/data/berserker.android.apps.sshdroid/home $ uname -a
Linux localhost 2.6.36.3-00004-g069b8b5 #1 SMP PREEMPT Wed May 11 22:14:22 CST 2011 armv7l GNU/Linux
/data/data/berserker.android.apps.sshdroid/home $ bash ./test.sh
sh: bash: Permission denied
/data/data/berserker.android.apps.sshdroid/home $ ls -l /bin/bash
ls: /bin/bash: No such file or directory
/data/data/berserker.android.apps.sshdroid/home $ find / -name "bash"
find: /config: Permission denied
lots more.......
find: /proc/595/task/598/fd: Permission denied
......
find: /data: Permission denied
find: /root: Permission denied
Follow up:
This is my script now which works:
#!/bin/sh
echo "hello wassup, run me simply as './test.sh'";
or
#!/bin/bash
echo "hello wassup, run me using 'sh ./test.sh'";
in Android the shell is located in /system/bin/sh not /bin/sh like it is on most Unix-like systems. So even if you change #!/bin/bash to #!/bin/sh it will still not work. you'll have to use #!/system/bin/sh
Android is not a GNU/Linux distribution so you can't expect that all scripts that run on GNU/Linux to also work on Android.
May be it will work when calling interpreter with a script?
$ bash ./test.sh
I saw, that although it is specified #!/bin/bash error was posted by sh - may be it do wrong.
UPD
$ sh ./test.sh
Most Android devices don't have a bash interpreter installed. If you really need to run the script across Linux and Android, you could try using BusyBox but that will require rooting your device (and potentially voiding your warranty). Even then though, I don't know if the ifconfig utility is included in BusyBox.
I would strongly recommend using the Android SDK to write an app to do whatever your trying to accomplish.
As was stated, the Android OS (up to and including 4.0) does not include the BASH interpreter (just shell). While BusyBox is a great tool, I believe it's only a single executable that combines stripped-down-functionality-for-size versions of common UNIX utilities, but doesn't actually include the BASH interpreter.
For an Android compiled version of the BASH interpreter, refer to this Forum thread:
http://forum.xda-developers.com/showthread.php?t=537827
You can install Busybox, which provides you with many utilities such as awk, file, etc... and Terminal Emulator.
Create a shell file with #!/system/bin/sh as the first line (shebang)
Now place the completed script under /system/xbin or /system/bin and run it from the Terminal Emulator
The information is an excerpt from this article : HOW TO RUN SHELL SCRIPTS ON ANDROID DEVICES
I have downloaded the android SDK 8 for linux and following the tutorial typed:
#tools/android update sdk
bash: tools/android: Permission denied
So I tried:
#sudo tools/android update sdk
sudo: unable to execute tools/android: Permission denied
Permission denied is because you are trying to execute something from a noexec mounted partition. Either mount with exec rights or use sh ./script. In your case:
cd tools
sh ./android sdk
To remount with exec rights:
sudo mount -o remount,exec /dev/yourpartition
it is generaly caused by the files of java, you need to change the rights of the java files in the /usr/bin/
to do that you can execute:
sudo chmod +x /usr/bin/java
sudo chmod +x /usr/bin/javac
sudo chmod +x /usr/bin/javaws
sory for my bad english