Actually, I retract that, after checking our implementation, it always do a
"sh -c <parameters>" so calling a shell script should work.
Have you tried checking the return value and errno after the call ?

On Wed, Feb 11, 2009 at 10:35 PM, David Turner <[email protected]> wrote:

>
>
> On Wed, Feb 11, 2009 at 7:32 PM, fadden <[email protected]> wrote:
>
>>
>> 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.
>>
>> it's a feature of the C library; and I don't think we have that
> implemented in Bionic
>
>
>>
>> > 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