How to execute Shell script in android

287 views
Skip to first unread message

Vikas KM

unread,
Apr 9, 2012, 8:20:40 AM4/9/12
to android-porting, andro...@googlegroups.com, andro...@googlegroups.com
Hi All,

I want to execute a shell script in android

*************** SHELL SCRIPT ********************

 if [ ! -d "/sys/devices/platform/ehci-omap.0/usb1/1-2/1-2.4" ]; then
    if [ -d "/sys/devices/platform/ehci-omap.0/usb1/1-2" ]; then
        NUMINTERFACE=`cat /sys/devices/platform/ehci-omap.0/usb1/1-2/bNumInterfaces`
    fi
 fi

********************************************************

That is based on the path if it exists, I want to run another script...

But i m unable to run the below script any idea what might be wrong?

I have root shell...


# sh ($PATH)/script_name.sh   Command i m using.


--------------
Regards

Vikas KM

Chris Stratton

unread,
Apr 19, 2012, 3:57:04 PM4/19/12
to andro...@googlegroups.com, android-porting, andro...@googlegroups.com
On Monday, April 9, 2012 8:20:40 AM UTC-4, Vikas KM wrote:
I want to execute a shell script in android

*************** SHELL SCRIPT ********************

 if [ ! -d "/sys/devices/platform/ehci-omap.0/usb1/1-2/1-2.4" ]; then
    if [ -d "/sys/devices/platform/ehci-omap.0/usb1/1-2" ]; then
        NUMINTERFACE=`cat /sys/devices/platform/ehci-omap.0/usb1/1-2/bNumInterfaces`
    fi
 fi

********************************************************

That is based on the path if it exists, I want to run another script...

But i m unable to run the below script any idea what might be wrong?

Various things... but it's likely not relevant.

Take a step back and tell us what you are trying to accomplish.  It appears you are trying to create a shell variable or modify an environment variable based on the existence of a file.  Unless you are doing system programming (in which case you should be asking on android-porting) that's note really an android way of doing things and would be pointless anyway as the variable would not propagate anywhere.  On android, whatever app needs to know this information should be finding it out via an android-style ipc or property mechanism, or simply doing the checking itself.

Ivo Topchev

unread,
Apr 19, 2012, 4:29:28 PM4/19/12
to andro...@googlegroups.com
Install busybox and it does most of the scripts, Google it and you will see what are the steps. 
Ivo

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/UZF3Z1ua_awJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages