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 8088287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:02:44+00:00 2026-06-05T19:02:44+00:00

On a rooted android device, I tried to run a cat command that read

  • 0

On a rooted android device, I tried to run a cat command that read kernel log, as follow:

Process p = Runtime.getRuntime().exec("su");
p = Runtime.getRuntime().exec("/system/bin/cat /proc/kmsg");

The su command was successfully executed but not the cat.
I tried to read the output of the command using getInputStream() but nothing was there, as follow:

BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
 while ((read = err.read(buffer)) > 0)
 {  //read error to buffer 
catOutput.append(buffer, 0, read);
 }
 in.close();

I used the same code with ls command instead of displaying the kernel log, it worked just fine and show me the result.

I wonder if what error I am getting and wantted to see the error message on the shell when executing the cat command. Tried the p.getErrorStream() but it doesn’t give me any result.
Could any one help me with this ? 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-05T19:02:46+00:00Added an answer on June 5, 2026 at 7:02 pm

    I finally found the solution for the problem by using RootTools library.
    Recently released (few months after my question was asked), RootTools provides a easy-to-use tool set that helps running commands that required root privilege. I created a wrapper to check if root access is available before executing shell command:

    void testRootToolsCommand(String command){
    
        if (RootTools.isRootAvailable())
            toastMessage("Root is available !!!");
        else { 
            toastMessage("NO ROOT !!! ");
            return; 
        }
    
        int timeOut = 1000; 
        try {
            List<String> output = RootTools.sendShell(command,timeOut);     
            toastMessage("OUTPUT of the command \n" + output.toString());           
        } catch (RootToolsException re) {
            toastMessage("Funny thing happened with RootTools!!! ");            
        } catch (TimeoutException te)
        {
            toastMessage("Timeout exception - Increase timeout !!! !!! ");
        }
        catch (Exception e) { 
        toastMessage(e.getMessage().toString());
        }       
    }
    

    An example of a function call is:

    testRootToolsCommand("cat /proc/kmsg > /sdcard/jun11_4h51.txt");
    

    Note: The Tool also support running multiple commands at once.

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

Sidebar

Related Questions

I connect to my rooted phone through adb shell command and I run the
I have successfully rooted my Samsung Galaxy Mini (android 2.2.1) and thought, that I
Possible Duplicate : what does the su mean: process = Runtime.getRuntime().exec("su"); I am tired
while i add this line to my code Process process = Runtime.getRuntime().exec(su -c); or
Android version: 2.3.7 Kernel version: 2.6.35-14-CyanogenMod-Arco-Kalim arco@tuxbox #1 Mod version: CyanogenMod-7.1.0.1-click The device has
Subject of discussion: User security on non rooted Android phones. Is it possible to
I'm writing an MMS/SMS application on a rooted Android 2.3.3 htc incredible S with
I have rooted my device and I have install busybox. Now I want to
I've an application,it has a data base.I've rooted my device.When i click data folder,it
I have a MyTouch 3G running Android, which has been rooted. I was wondering

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.