Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:36:10+00:00 2026-06-01T09:36:10+00:00

All Here i want to run .sh file via system call in android NDK.

  • 0

All

Here i want to run .sh file via system call in android NDK.

I able to run cp,rm command via system call. but sh command is not working via system call.

I also installed busy-box on android.I am using below code.I set all permission on test.sh.

Code :

#include <stdlib.h>
#include <stdio.h>
#include <android/log.h>
#include <jni.h>

#define LOG_TAG "Demo"

#define LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)


void Java_com_ndkdemo_NDKdemoActivity_systemcall(JNIEnv * env, jobject obj) {

    int result;

    result = system("cp /mnt/sdcard/test /Download");

    LOGD("result is cp %d", result);

    result = system("sh ./test.sh");

    LOGD("result of test.sh is %d", result);

}

Output :

 result is cp 0.
 result of test.sh is 0.

Here i am getting 0 in system("sh ./test.sh"); but not started the test.sh script.

cant get output "Hi" on console.

test.sh contains

#!/system/bin/
echo "Hi"

If i am executing direct command on prompt than its working fine and its given output "Hi" on console.

Please Help me to figure out this issue.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:36:12+00:00Added an answer on June 1, 2026 at 9:36 am

    Where are you expecting to see the “echo”? By default, android sends stdout to /dev/null.

    According to the documentation you can redirect stdout and stderr to the log (so it will show up in logcat) using the following commands:

    $ adb shell stop
    $ adb shell setprop log.redirect-stdio true
    $ adb shell start
    

    Now you may see your echo in adb logcat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I want to achieve here is to shrink all of the Android's OS
all I want to run instruments from console, here is the usage output: usage:
Here's what I'm doing. I want to upload multipart file via Ajax to my
I want to run three php scripts one after another from one file. all
Need a little help with my jquery here I want all my button with
Here is my script... all I want to do is have it continuously loop!
I want to list all users with their corropsonding user class. Here are simplified
Here's what I'm trying to do: I want to get a list of all
here i want to run this program and take one character pointer like char
Here is the script that I want to run using git filter-branch : #!/bin/bash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.