Sorry for not explaining it quite clearly the first time. So those 2
little code snippets I just posted above, those are from the
ds2784battery class we used in my app, near the end of the file.

Those are actually using the shellcommand class we imported. And when
those code snippets give you the actual result of whatever command you
put in quotes, and return it to you as a string.

However you also could just look right at the shellcommand class and
see the inputstream code right from the try catch statements and
mimick that in your code. But we just used the class to make it easy
since the work is there done already.

Hope this helps a little.

On Jan 7, 8:00 am, Jay <j.gato...@gmail.com> wrote:
> I see,
>
> I'll take another look.
>
> Thanks,
>
> On Jan 6, 5:14 pm, Roger Podacter <rogerpodac...@gmail.com> wrote:
>
>
>
> > what doesnt make sense?  i'll use the two commands we used as example,
> > "cat" and "echo".  we had to use those two.  the shellcommand works
> > for both root access, and non-root if that's what you want.  from the
> > code all we did is:
>
> > ShellCommand shell_command = new ShellCommand();
> >                         CommandResult command_result = 
> > shell_command.sh.runWaitFor("echo
> > xx");
>
> > replace whatever terminal command you want between the quotes ""
> > there.
>
> > you could also do that same command as root access (not really
> > relevant here, just example) by replacing the SHELL with SU, so:
>
> > CommandResult command_result = shell_command.su.runWaitFor("echo xx");
>
> > me and my partner wrote the battery calibrator app.  but we just asked
> > for permission from the guy who wrote the shellcommand class.  sorry i
> > dont know his name, my bud contacted him.  but there is a short thread
> > on XDA about it.  sorry there's not any docs that i know of.
>
> > i linked you to it because the shellcommand does show how to get the
> > inputstream and all.  you likely could just take just that portion
> > from the try/catch commands, and put it into your own code to run the
> > exec call and all.  otherwise you could see about just including the
> > entire shellcommand class in your code like we did.
>
> > On Jan 6, 1:57 pm, Jay <j.gato...@gmail.com> wrote:
>
> > > The terminal emulator code doesn't make since to me. Looks like
> > > there's some native code stuff going on in there.
>
> > > As for the battery calibration app, who exactly wrote the
> > > ShellCommand.java file, and is there any documentation to go with it?
> > > It sort of makes sense, but I can't piece it together. A google search
> > > didn't turn up much.
>
> > > Thanks
>
> > > On Jan 4, 3:42 pm, Dianne Hackborn <hack...@android.com> wrote:
>
> > > > Note that shell commands are not part of the SDK, so there are no 
> > > > guarantees
> > > > that commands you are executing will continue to work in the future.
>
> > > > On Tue, Jan 4, 2011 at 1:34 PM, Jay <j.gato...@gmail.com> wrote:
> > > > > This is exactly the kind of stuff I was looking for.
>
> > > > > I'll dig in, thanks.
>
> > > > > On Jan 3, 11:25 am, Roger Podacter <rogerpodac...@gmail.com> wrote:
> > > > > > i just replied to this thread but i guess i'm new so the post didnt 
> > > > > > go
> > > > > > thru?
>
> > > > > > i just used "cat" and "echo" commands in my app we just finished
> > > > > > recently.  the person above who mentioned getting the InputStream is
> > > > > > correct.  i cant paste in the entire code example, but if you search
> > > > > > the web for "shellcommand" this is already developed to allow you to
> > > > > > easily perform terminal commands of this nature in your java code.  
> > > > > > it
> > > > > > clearly shows how to get the exec call return etc.
>
> > > > > > i linked the source code of my app for reference on github, but i'm
> > > > > > probably not allowed to post links yet.
>
> > > > > > hope this message goes thru this time.
>
> > > > > > RP
>
> > > > > > On Jan 3, 8:01 am, FrankG <frankgru...@googlemail.com> wrote:
>
> > > > > > > Seems that you are looking for a terminal emulator like this one 
> > > > > > > ..
>
> > > > > > >https://github.com/jackpal/Android-Terminal-Emulator/wiki
>
> > > > > > > Good luck !
>
> > > > > > >   Frank
>
> > > > > > > On 31 Dez. 2010, 22:48, Jay <j.gato...@gmail.com> wrote:
>
> > > > > > > > I started reading that, but it still doesn't complete sense. Are
> > > > > there
> > > > > > > > any other more descriptive documents on this out there?
>
> > > > > > > > On Dec 30, 7:33 pm, jotobjects <jotobje...@gmail.com> wrote:
>
> > > > > > > > > You get an InputStream from the Process returned by the exec 
> > > > > > > > > call.
> > > > > > > > > Read and study the javadoc for java.lang.Runtime an
> > > > > java.lang.Process.
>
> > > > > > > > > On Dec 30, 3:14 pm, Jay <j.gato...@gmail.com> wrote:
>
> > > > > > > > > > I also want to be able to run commands like 'ls' and 'cat'
>
> > > > > > > > > > On Dec 30, 5:09 pm, Jay <j.gato...@gmail.com> wrote:
>
> > > > > > > > > > > Hello,
>
> > > > > > > > > > > Here's what I'm trying to accomplish: I want to be able 
> > > > > > > > > > > to show
> > > > > dmesg
> > > > > > > > > > > logs and logcat output in an app I'm writing. I know that 
> > > > > > > > > > > I'm
> > > > > supposed
> > > > > > > > > > > to use Runtime.getRuntime().exec(), however other than 
> > > > > > > > > > > that,
> > > > > I'm
> > > > > > > > > > > pretty lost. I tried to find some examples, but couldn't.
>
> > > > > > > > > > > Can someone here give me some information on how to do 
> > > > > > > > > > > this?
> > > > > Maybe
> > > > > > > > > > > point me to some example code. Aside from doing the 
> > > > > > > > > > > following
> > > > > in my
> > > > > > > > > > > code:
>
> > > > > > > > > > > Runtime.getRuntime().exec("dmesg");
>
> > > > > > > > > > > or
>
> > > > > > > > > > > Runtime.getRuntime().exec("logcat");
>
> > > > > > > > > > > I'm not sure what else to do to be able to read dmesg and
> > > > > logcat
> > > > > > > > > > > outputs.
>
> > > > > > > > > > > Thanks,- Zitierten Text ausblenden -
>
> > > > > > > > - Zitierten Text anzeigen -- Hide quoted text -
>
> > > > > > > - Show quoted text -
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to 
> > > > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs
> > > > >  ­cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > Dianne Hackborn
> > > > Android framework engineer
> > > > hack...@android.com
>
> > > > Note: please don't send private questions to me, as I don't have time to
> > > > provide private support, and so won't reply to such e-mails.  All such
> > > > questions should be posted on public forums, where I and others can see 
> > > > and
> > > > answer them.- Hide quoted text -
>
> > > - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to