Command Shell for a mobile phone

孤街醉人 提交于 2020-01-06 16:51:50

问题


I am working on a project for builiding a shell for a java enabled mobile phone(using J2ME).I have to demonstarte 3 commands 1) ls 2) top 3)cat .How to implement them?Plese give me some ideas.Thanking you.


回答1:


Download Coreutils (it's the package which contains all of these commands): http://ftp.gnu.org/gnu/coreutils/coreutils-8.9.tar.gz.

Rip it open, and find the source code for each one. I think the tarball is organized quite nicely.

And some implementations of the commands in other languages (I like Python, as it's readable):

  1. ls: http://www.pixelbeat.org/talks/python/ls.py.html.
  2. cat: http://www.unix.com/302420159-post2.html.
  3. top is complicated. Good luck implementing it!



回答2:


You can use JSR 75 [File Connection API] to list out the files, which can be used to implement 'ls' command and using the same, you can implement the 'cat' command also.

However beware of the permissions, your app needs to be signed to be effective, otherwise for each subsequent requests to the file-system, the OS will be asking the user for permission, destroying the concept of a shell!

'top' can't be implemented in J2ME

Sample for File Connection API: File Sample



来源:https://stackoverflow.com/questions/5666514/command-shell-for-a-mobile-phone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!