On Feb 11, 8:13 am, David Turner <[email protected]> wrote:
> you can't use system() to call a shell script, you need to invoke the shell
> interpreter instead, with something like "/system/xbin/sh
> /system/xbin/test.sh"

I tried it just now from a trivial C program; worked fine.  I'm not
sure why it would be different from inside the Android app
environment.


> On Wed, Feb 11, 2009 at 1:54 PM, Corey <[email protected]> wrote:
> > I write an API in C by using system("/system/xbin/test.sh"); funtion,
> > and then my Java code will use this c API code to execute this shell
> > script.
> > However, it seems nothing happens.
> > Can I call a shell script from JNI?

Make sure you have the right "#!" line -- "#!/bin/sh" will not work,
since the shell doesn't live there.  For example:

  #!/system/bin/sh
  echo hello >> /sdcard/foo
  exit 0

Bear in mind that stdin / stdout / stderr are redirected to /dev/null
by default, so you won't see any output.

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---

Reply via email to