Runtime.getRuntime().exec("su")
Keeps returning error "Permission Denied"
Any ideas?
White list permission has been added with same results
pentace said:
Runtime.getRuntime().exec("su")
Keeps returning error "Permission Denied"
Any ideas?
White list permission has been added with same results
Click to expand...
Click to collapse
06-03 18:55:23.125: WARN/su(3478): request rejected (0:0->0:0 /system/bin/sh)
chmod su to 777
neoobs said:
chmod su to 777
Click to expand...
Click to collapse
So say i wanted to go to view data directory
Runtime.getRuntime().exec("chmod 777 su ls /data")
fails
would you mind giving a small example please?
No on your phone you have to chmod 777 su before you can start using the exec command.
However I believe you can't run the exec command as root, maybe you can sudo but I don't think sudo is enabled by default.
I already chmod 777 su on the phone. i even did it again to make sure so i thought you were talking about doing it via code some how.
there has to be a way. from what ive see that is what GScript uses.
So somehow when i chmod 777 su again i completely lost root access on my phone i tried going through the recovery console and chmod again but its wont return
I was having the same issue and had to rm su and then cp it back chmoding it again
yeah i tried through recovery but its screwed up now.. ah well havent flashed it since day one minus well to clean up the huge mess ive made in it over the months lol
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
i think that if you do:
su (to get superuser privileges)
sh your_script.sh
might work....
alternative is to install gscript and put your script in the gscript folder on sdcard....
The console needs to be granted superuser access, then ran as sh script.sh or bash script.sh. afaik at least. Youll probably have to use su like the person above said.
I did the su command. But i still can't open it. All other commands work.
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
ryocoon said:
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
Click to expand...
Click to collapse
This should be the solution. X is the execute bit. Basically without that bit set on the file permissions, the OS won't allow that file to be executed as a program.
chmod +x filename.sh
Try running that command in terminal emulator and it should clear things up.
Sent from my Inspire 4G using XDA App
I used that command and it said 'bad mode'.
It still doesn't work.
If you are running the script with this:
Code:
sh script.sh
then the executable bit doesn't need to be set in order to execute it, since you are specifying 'sh'. If you were trying to run it with this:
Code:
./script.sh
then it would require the executable bit to be set.
In an attempt to answer the question, where abouts is your script saved and which user owns it? Just as a quick test on mine, I made a script named test.sh (containing the same lines as yours) on the root of my sd card, cd'd to it and ran sh test.sh, and that seemed to work. That script ended up being owned by 'system'.
As a test to make sure sh is behaving, can you run the following from the terminal:
Code:
sh -c 'echo hello'
EDIT: note that all of the above was run as a regular user, not root.
Yeh it said hello when i did the command you said.
It must be a problem with the file in some way then. Can you run the following from the folder that your script is in and give the output?
Code:
ls -l | grep script.sh
Also, what did you use to make the script - terminal in Android, or adb'd it from your PC etc?
(Aside: just a thought, you probably can't do chmod's on sdcard files if it's formatted to FAT32 since FAT32 doesn't understand Linux permissions)
you can also try an app i found some time ago. SL4A
I made the file with silveredit. Just renamed .txt to .sh.
Btw i got it working with gscript, thanks for everyone's help
Run a reverse tethering shell script
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
nok2626 said:
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
Click to expand...
Click to collapse
it's because android doesn't know about these command, this is a native linux command, try to install busybox, edit your script like this
Code:
busybox ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
busybox route add default gw 192.168.137.1 dev usb0
busybox setprop net.dns1 8.8.8.8
busybox setprop "net.grps.http-proxy" ""
I hope these helpfull
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
Even though your device is rooted, android environment won't allow applications to execute 'sh' commands.
As android security architecture says, applications run within a secured execution space inside Application Sandbox, sh execution can bypass this security.
If there are any exceptional cases where few devices allow 'sh' execution, well... OEM's needs to be reviewed again.
Answer
Maybe you can try the method that I have specified and check whether it works
http://forum.xda-developers.com/showthread.php?t=2620394
krutle said:
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
Click to expand...
Click to collapse
the script is already run and no need to type the command again, note: some script files can damage your system if run twice
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
You have to put the script somewhere that it has permission to execute from, copy it to /data/local/tmp first. Then in your terminal run each of these commands;
su
cd /data/local/tmp/
chmod 0755 MyScriptName.sh
./MyScriptName.sh
So I,m having this issue CM 7.1.0 Wifi issue . In Iv tried this
"once you have the wlan_loader binary (you can unzip from the rc1 rom):
adb remount
adb push wlan_loader /system/bin
adb chmod 755 /system/bin/wlan_loader"
And also this
"I've got it!
Here is wlan_loader: h t t p://db.tt/jwdh4Izj (remove spaces)
Copy this to system/bin/
Then open terminal emulator and write: su.
Then write: chmod 755 /system/bin/wlan_loader ...... as said Diego.
Ok?"
But when i tried to use the comands in terminal i got some errors two different about adb not found or something like that (cant quote atm sorry) and figured that my system file is locked somehow. I tried to find a way around it and tried some -r remount commands (cant remember them exactly eather)
Anyhow it would be awesome if somone culd tell me how to solve this I read something about that it shuld be solved in some nightly build but I dont dare to change rom again atm. As u can gues Im new to this =P
Thx in advice
"
So now Iv finaly managed to get the wlan_loader into /bin but now when i type "chmod 755 /system/bin/wlan_loader" Still nothing back from terminal. Just an update if somone decided to help me ^^
Btw i found out that Iv posted this at the wrong place. Sorry for that, if possible pls move it
I have my Polaris NAND flashed with 2.6.25 kernel + casacristo's RLS18 ROM.
I have updated from the market the Superuser but now I get the pessage that SU is not updated and to download the new one (3.0.3.2).
I download the new one , the Root access is granted but at the end more or less I receive this message translated from italian:
...
...
md5sum ... OK
Mod file su 06755... OK
Moving su to its final position ... failed...
TRY Again
I tryed several times but ... no chance to update it... how can I manage ?
miazza
Here is latest su binaries v3.0.3.2. Download and unzip file. Push this to /system/bin and /system/xbin and then change rights with chmod to 6755. Reboot phone. Done.
Thanks, I will try.
Shall I do via ADB or can I try with RootExplorer for example ?
miazza
ADB, unless your root explorer can set 6755 rights
whitealien said:
ADB, unless your root explorer can set 6755 rights
Click to expand...
Click to collapse
It worked great. I managed with RootExplorer but it can be done also via FTP with Filezilla.
Thanks
miazza
file permissions doesn't work
Hi,
I use a HTC wildfire S, who have been rooted, but still in original ROM.
My SU doesn't want to be updated, as described in the first post.
So I downloaded the ZIP, and put SU on the sdcard. With ROOT BROWSER I copy it on /system/bin (SU have been copied automaticaly in /system/xbin).
I tried to change the permissions files, but after reboot, permissions are ---rwxr-x.
I tried with ADB. My phone is well recognised :
C:\Program Files\Android\android-sdk\platform-tools>adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached
SH191TR05136 device
When I tried to change permissions file SU :
C:\Program Files\Android\android-sdk\platform-tools>adb shell
adb server is out of date. killing...
* daemon started successfully *
$ chmod 6755 /system/bin/su
chmod 6755 /system/bin/su
Unable to chmod /system/bin/su: Read-only file system
$ chmod 6755 /mnt/sdcard/temp/su
chmod 6755 /mnt/sdcard/temp/su
Unable to chmod /mnt/sdcard/temp/su: Operation not permitted
$ chmod 755 /mnt/sdcard/temp/su
chmod 755 /mnt/sdcard/temp/su
Unable to chmod /mnt/sdcard/temp/su: Operation not permitted
$
Do you have an idea ? Thanks by advance, because right now, my phone is not still root...
I have no idea about how ROOT BROWSER works.
With RootExplorer you can tap the su file and keep it untill the permission window appear. At that point you can change all the file rights.
Another way for doing it is via FTP by using SwiFTP.
ciao
miazza
miazza said:
I have no idea about how ROOT BROWSER works.
With RootExplorer you can tap the su file and keep it untill the permission window appear. At that point you can change all the file rights.
Another way for doing it is via FTP by using SwiFTP.
ciao
miazza
Click to expand...
Click to collapse
Root browser seems to work the same way.
How can you use FTP with a phone ? It's suppose to use an IP adress. But by USB, there is not... But I will,l try asap.
However, my apps couldn't take root permissions, so I feel bad...
Use SwiFTP (it should be free from the market).
It works over Wireless connection to your internal WLAN and provide you with an FTP address like 192.160.0.x.
While you are connected through FTP client (like Filezilla), you can see your mobile File System as well as your SD.
with a right click on the su file you can change your rights.
But I do not know if it works even if you are not rooted...
miazza
I solved my problem my re-rooting my phone, using http://forum.xda-developers.com/attachment.php?attachmentid=672519&d=1312136127.
My phone says that the binary SU was obsolete, but when I tried "AGAIN" to update it, it was successful that time.
Strange, I don't understand why now the update was ok. But all is right.
Thanks everyone for the help.
I have found that my LG G5 /sdcard/DCIM has access permission of 0x770. I suspect this is the reason that video files are not visible when I connect it to my PC using MTP mode.
So I tried to change it. First, tried ES File Manager with root turned on and / mounted rw. However, properties of the folder does not have any way to change access permission.
So I installed Terminal Emulator and su to root. chomd 777 does not work -- it reports no error but the result is 771. chmod a+rwx or chmod o+rwx does not work either.
How could I change the permission?
Thanks