Android Question Put a command on shell

Discussion in 'Android Questions' started by klingon467, Jun 11, 2015.

  1. klingon467

    klingon467 Member Licensed User

    Hi,
    i want to send a command into shell on my device i use this:

    Code:
    Sub rShellExecute (Command As String)
    Dim Runner As String
    Dim StdOut, StdErr As StringBuilder
    StdOut.Initialize
    StdErr.Initialize
    Dim Result As Int
    Dim Ph As Phone
    Runner = 
    File.Combine(File.DirInternalCache, "Runner")
    Command = 
    File.Combine(File.DirInternalCache, "command")
    File.WriteString(File.DirInternalCache, "Runner""su < " & Command)
    File.WriteString(File.DirInternalCache, "command""modprobe cifs" & CRLF & "modprobe aufs" & CRLF & "exit"'Any commands via crlf, and exit at end
    Result = Ph.Shell("sh"Array As String(Runner), StdOut, StdErr)
    Log(Runner)
    Log(StdOut.tostring)
    Log(StdErr.tostring)
    i can send a command into "Command" variable?
    for example, to see a list of the root file and folder?

    cd /
    ls -lrt

    thanks
     
  2. DonManfred

    DonManfred Expert Licensed User

    If your device is rooted (must be to access this folder) you can try RootCMD library
     
    klingon467 and lemonisdead like this.
  3. klingon467

    klingon467 Member Licensed User

    awesome!!! :eek:
     
  4. klingon467

    klingon467 Member Licensed User

    sorry i can put my command so? @DonManfred

    Code:
    Sub rShellExecute(command As String)
    Try
    rc.execRootCmd(command)
    Log(command)
    Catch
    Log(LastException.Message)
    End Try
    End Sub
    usage: rShellExecute("ls -lrt")
    to see the output of the command to log?
     
  5. DonManfred

    DonManfred Expert Licensed User

    I dont know whether this lib captures the output or not.
    I would try to call a command which prints the ls output to a file and after that i would try to read that file.
     
  6. klingon467

    klingon467 Member Licensed User

    i use your lib but i have this error:

    Code:
    mHaveRoot = true, have root!
    mHaveRoot = 
    true, have root!
    pm install -r /mnt/sdcard/catturascreen.apk
    java.lang.RuntimeException: Object should first be initialized (
    Exception).
    for install apk i use this:
    Code:
    Sub InstAPK(apkfile As String)
    If rc.haveRoot Then
    If rc.InstallApk(File.DirRootExternal & "/" & apkfile) Then
            manna(
    "APKINSTlog" & "SPLT" & "Install success")
        
    Else
            manna(
    "APKINSTlog" & "SPLT" & LastException.Message)
    End If
        
    Else
            manna(
    "APKINSTlog" & "SPLT" & "There is no root!")
    End If
    End Sub
    usage: InstAPK("catturascreen.apk")

    What needs to be initialized??
     
  7. DonManfred

    DonManfred Expert Licensed User

    It is not my lib. I just know of the existence of it so i wrote it here.
    Maybe @icefairy333 can answer your issue as he is the author of this lib.
     
  8. klingon467

    klingon467 Member Licensed User

    @icefairy333
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice