0

I am trying to mount USB pen drive in my old Xperia phone running andorid 4.1.2 When I connect OTG device to my phone I get an USB power consumption error.

After little search I found a command to make it work.

su
echo 1 > /sys/bus/usb/devices/1-1/bConfigurationValue

When I execute this command from Terminal Emulator it works perfectly and USB drive is detected by my phone.

To avoid typing this command I am trying to created a Shell script which will run this command automatically using SManager:

Shell Script SManager Config
Shell script (left) and SManager Config (right; click images for larger variants)

When checked the log file i got only one line: script started

SManager executes it as:

# /system/bin/sh /storage/sdcard0/myusb.sh

I am not able to find out where I am going wrong. Need help!

  • I'd have the script log something to see if it is really executed (successfully). Include e.g. echo "Script started" >> /sdcard/myusb.log before the su command, and echo "Return code is $?" >> /sdcard/myusb.log at the very end, followed a cat /sys/bus/usb/devices/1-1/bConfigurationValue. Then you can evaluate the log to see whether a) the script was executed at all, b) the command succeeded, and c) the value was set. – Izzy Mar 18 '15 at 13:57
  • @Izzy: I have followed your instructions and updated the script. It gets stuck at the su command itself. Not sure whats wrong. I have updated the question to include the changes. Please have a look. – Nilesh Barai Mar 18 '15 at 19:31
  • Any popup from the SuperUser app? Does SManager support root executions? If so, can you directly advice it to have the script run as root (so you wouldn't neet the extra su in the script itself)? – Izzy Mar 18 '15 at 22:20
  • @Izzy: there is this SU option in the second screenshot. Maybe I will have to dig in more. I will let you know by evening. :) – Nilesh Barai Mar 19 '15 at 4:08
  • Sure. Other than on the shell, apps must explicitly support root – and register with the SuperUser/SuperSU app installed. AFAIK you cannot simply run a script calling "su". SManager seems to support this (by the screenshot). I'd say you need to activate the "Su" option there, and kick it out of the script – then it should work. – Izzy Mar 19 '15 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.