Want to run script file using system call in android NDK

10,230

Solution 1

Here i got the answer of this Question on Different post.

Run Shell Script file On Android Embedded Device using System function in Android NDK

thanks to all for Help

Solution 2

where is 'sh'? and what is your '.' current directory when the application runs? try:

result = system("/system/bin/sh /full/path/to/test.sh");

Share:
10,230
user1089679
Author by

user1089679

Updated on June 04, 2022

Comments

  • user1089679
    user1089679 almost 2 years

    I want to run script file on android Shell using Native C program.

    I tried using system function but it's not working.

    result = system("sh ./test.sh");
    
    LOGD("result is %d", result);
    

    system command returns 0 means its not executed script file successfully.

    test.sh contains

    echo "test...."
    

    Android NDK application could not print test.... when this system call runs.

    Even any script can not be started using system call. i checked more than 10 different scripts.

    test.sh have 777 permissions

    Any help would be appreciated.