How to write scripts for android - General Questions and Answers

I'm more of an Desktop programmer, writing all the background work and shying away from the GUI stuff. I'm good with commandline scripting type work, and stuff like that, but I want to create something for android that will access the filesystem and manipulate things in the system directory. How can I best accomplish this? I'd prefer a computer application, but I dont know how to write a program that will access things in the command line...

damastah said:
I'm more of an Desktop programmer, writing all the background work and shying away from the GUI stuff. I'm good with commandline scripting type work, and stuff like that, but I want to create something for android that will access the filesystem and manipulate things in the system directory. How can I best accomplish this? I'd prefer a computer application, but I dont know how to write a program that will access things in the command line...
Click to expand...
Click to collapse
Have you tried to simply write it with C, C++ or any other language you like and just crosscompile it to ARM? I don't see any reason why this doesn't work, when the programs are just for yourself
Greetings,
KanocX

Related

how to reboot from a WM user interface?

Hello the community
I would like to know how to perform a soft reset (reboot) from a WM user interface. Of course there is a lot of external programs and utilities providing such the functionality also, but I guess there should be a mechanism built in WM.
I am sure there should be a DLL responsible for that, so probably there is also a way to execute this DLL?! Something like Windows’ rundll.exe?
My device is HTC p3600/Trinity with WM5, but I think it doesn’t make sense.
Your advice would be much appreciated,
Br, Alexey
dll mean dynamic linked libary
which pretty much mean it's a lib full of functions that
other apps call you cant normaly just call it's functions from
the GUI
yes, I know what DLL actually mean
And that’s why I made a guess about a possible way to run DLL similar to rundll.exe
I would prefer using something like reboot.exe, but if such a program isn’t provided along with standard WM, I don’t mind using workarounds like running DLL, if possible.
Anyway, my question was not about real nature of DLL but the way how to perform a reboot using standard functions of WM.
Check out the SDK documentation, MS might have made a direct api to achieve this through a direct rundll type action, but the easiest way is just to code a tiny app and launch it, eg
http://www.pocketpcdn.com/qa/softreset.html
VJEschaton will reset in a variety of fashions.
V
Thanks
Is there a way to compile such a tiny application without installing any huge C++ IDE? Something like command line compiler downloadable thru a simple ZIP file?
shkaff said:
Thanks
Is there a way to compile such a tiny application without installing any huge C++ IDE? Something like command line compiler downloadable thru a simple ZIP file?
Click to expand...
Click to collapse
The C# compiler is free and can produce WM executables. The only problem is that you must instruct it to use the .NET Compact Framework libraries instead of the normal ones. I readied a guide when the last OS was WM2003. I don't know if it is still working, but actually I have no reason to think it won't. Just choose the right subset of files.
Here is the link:
http://www.jargoncode.it/tips/netcfcompile-eng.htm
If you want a C++ compiler... I don't know.

Jesusfreke. Can you or another programmer please consider this.

In the next update on the recovery console, would it be possible to add a script that when you type /? like in old dos commands, that you will get a list of bash commands? Or does such an animal already exist.
I have a copy of about 5 sheets of paper listing all linux bash commands (similar to dos but without all the syntax).
While updating one day, I messed up and started from that point on trying to learn the linux commands that copy files, rename files, remount /sdcard and so on. Its fairly simple, but it would be nice to do for example remount/? and give you the proper usage of remount and so on. I know most of you all are not DOS fans, but I need a ground zero to start from if i wanna learn the way this runs, without carrying around a stack of papers with me .
--help works eg. ls --help
dont have a g1 yet so cant try it out, but what if you try remount --help or maybe its just one -
i will try that
I didn't see it in the list.
i dont think that wud the greatest thing becuz wat if ur typing a message anything you type in can damage your phone
kay11224 said:
i dont think that wud the greatest thing becuz wat if ur typing a message anything you type in can damage your phone
Click to expand...
Click to collapse
Huh? Wah?
Well I tried --help
This only helps if you happen to know the bash command. It is a step in the right direction.
What I am referring to is a list of /? help files.
It is a list of commands to include such commands as ls, cp, rm, remount, cd .. and so on. The reason why I say it is because with a small description of the bash commands people that have a working knowledge of computers, but not neccessarily of linux would be able to use it.
I know eventually I will probably remember the commands or at least the ones most important to me. I only ask because it took me about 1.5 hours to figure out a simple delete filename X.zip (rm update.zip), Copy filename X.zip to /sdcard (cp blahblah.zip /sdcard), mv blahblah.zip update.zip.
It took me using another computer to figure out those simple commands. I know it seems like I am asking something very redundant and simple, but I don't understand why linux command line doesn't have a help list of terms.
It wasn't until I read these bash commands that it dawned on me that recovery.sh was the recovery script to be executed from the command line. I couldn't have used it anyways, because by then I had already messed that up too.
Suffice to say I got my phone up and running and I am feeling a little proud of figuring it out on my own.
Brutal-Force said:
This only helps if you happen to know the bash command. It is a step in the right direction.
What I am referring to is a list of /? help files.
It is a list of commands to include such commands as ls, cp, rm, remount, cd .. and so on. The reason why I say it is because with a small description of the bash commands people that have a working knowledge of computers, but not neccessarily of linux would be able to use it.
I know eventually I will probably remember the commands or at least the ones most important to me. I only ask because it took me about 1.5 hours to figure out a simple delete filename X.zip (rm update.zip), Copy filename X.zip to /sdcard (cp blahblah.zip /sdcard), mv blahblah.zip update.zip.
It took me using another computer to figure out those simple commands. I know it seems like I am asking something very redundant and simple, but I don't understand why linux command line doesn't have a help list of terms.
It wasn't until I read these bash commands that it dawned on me that recovery.sh was the recovery script to be executed from the command line. I couldn't have used it anyways, because by then I had already messed that up too.
Suffice to say I got my phone up and running and I am feeling a little proud of figuring it out on my own.
Click to expand...
Click to collapse
"bash comes with help for all built-in commands. To see a list of all built-in commands, type help. To obtain help on a specific command, type help command, where command is the command you need help on. Here's an example:
bash> help alias
...some help text...
Obviously, you can obtain detailed help on the bash shell by typing man bash at your command prompt at any time."
The shell on the G1 doesn't seem to support it though...you would be better off getting comfortable in a real Distro and then apply the knowledge on the much less robust G1
This isn't quite so simple on Android.
First, you're not using bash. You're using either the android shell which is pretty limited or you're using the busybox shell (reachable with "busybox sh") which, I believe, is bourne shell compatible, but lacks some new features of bash.
Busybox is an single executible that implements a bunch of the common linux command line utilities. You're intended to symlink a bunch of command names back to busybox, but last I checked, this wasn't done so as to avoid stomping on the native android commands. You may need to type "busybox <command>" to run the right one.
To get a list of supported commands, run busybox with no arguments. Some commands have a --help option, but that won't be helpful for much of them unless you're already familiar with them.
The full documentation for any command is available as a "man" page (manual) on most linux systems, but you're not going to see it on an embedded system like android. But if you do a google search for "man <command>", you can easily find them. Many of the less basic options listed in the man page may not be available in the busybox version.
To get a list of busybox commands just type 'busybox'
If it flies off the top of the screen, type 'busybox | more'
I hope that helps.
Thanx everyone for the replies.
I had already printed out a command list which I googled. I will definitely try the busybox command. Although computers are not new to me, linux is. I am just having a slow time getting started, especially since busybox really isn't linux.
Why developers won't implement this request:
Brutal-Force: It's good that you got an answer by printing out a reference. That definitely will help you. Most of the utilities in JF's images support the standard GNU format of --help instead of /? so you're most of the way there.
Now, here are some reasons you won't get your actual request.
1) ? in the sh style shells is a protected character. To get remount /? you would actually have to type remount /\? or remount '/?'
2) All of the applications themselves would the have to be changed. Their relevant "getopts" or self-implemented methods of reading cmdline options would have to have the /? added to them. There's not a common point to change there. A quick count shows me over 150 different applications that would have to be changed.
3) It's ridiculous to cater to such a small crowd for something that is so labor intensive and can be done better with a simple documentation search.
Now go forth and RTFM. You'll be a better hacker for it.
note: JF likes notes. So do I.
note: A "hacker" is somebody like JF who makes hackable things do what hacker wants. Those other malicious @$$holes are called crackers. We don't like them.
whoa whoa whoa
First and most importantly,
BASH != DOS
Ever. Period. Don't even compare the two.
That said, learn how to google. BASH is very complicated with tons of command, keywords, etc. It is a scripting language after all.
Now, I do not see how it took you 1.5 hours (!) to figure out cp, as the first result of 'bash + how to copy files' in google gives you a link to all you could want to know.
For a complete list of command, type 'man busybox' in google and you are all set. Infact 'man YYY' will give you the manual for any command in Linux. Bash is not for those who do not want to learn, but, if one does learn it, there is no turning back from its goodness
Ok, Please take it easy on me.
This was not a "compare dos with linux" thread.
It was not a make my work a little easier thread.
I was updating 1.41 RC33 themes "AS USUAL". One of the theme designers made a boo boo. My phone went into loop while I was at work. The only computer I have access too does not have a USB port and is a Network computer that does not allow me access to this site. That being said, the only reference I had was to google linux commands. From the printout I had to figure out what does what. cp does not equal copy even though it shares two of the same letters. mv does in no way resemble rename so how on earth was I supposed to equate the two.
The problem with most people who already know linux is that they are not as helpful as a Dos or Windows "?" If they were I am sure there would be alot more people willing to give it a try. This is not really a rant, but I was asking for help, not begging to be tortured.
A few of the answers i.e. busybox helped. I did not know this, and at the time I could not look on the forum for help. I do not know about these other commands as well. Despite all that I was able to figure it out from a printout, I was just saying that knowing the list of Android based unix commands with a small one or two word description would go a long way.
P.S.
Thanx Just, Tiber and Boogie for helping me and not flaming me.
Bagkawilo
"Now, I do not see how it took you 1.5 hours (!) to figure out cp, as the first result of 'bash + how to copy files' in google gives you a link to all you could want to know."
See here is where you let your mightier then thou attitude get in your own way. For the record, that was exactly the pages I have printed out. Additionally, those pages give you way to much information to perform a specific task such as copy. Now, if i had gone to cp (Which again by the way does not mean copy to me, yes I might have figured it out quicker) but to me cp might as well have been cd.
Before I even got to that command I first had to figure out how to even access my sdcard. Next because this IS NOT DOS changing directories is, while similar, NOT THE SAME. What you have been practicing for quite some time may seem quite trivial to you, but for others its like learning a new language. I could perform the same functions in Dos or Paschal (The programmers language I learned in 15 years ago), BUT I am trying to learn YOUR language.
Seriously, I hope you never have kids who ask you how to do homework.
Just a thought
Brutal - I hope you don't think I was flaming you (you didn't mention me), because I certainly wasn't. It does come to my attention, though, that perhaps having root access on a bleeding edge image on a Linux based phone without any Linux experience is maybe like learning to pilot the Death Star before you figure out how to change the batteries in your light saber. It's good that you're learning along with the rest of us, hang in there. My recommendation: go download a copy of Slackware Linux and install it in a VirtualBox machine. Break it. Fix it. Learn how you fixed it. Break it some more.
/Just sayin...
ccosby said:
It does come to my attention, though, that perhaps having root access on a bleeding edge image on a Linux based phone without any Linux experience is maybe like learning to pilot the Death Star before you figure out how to change the batteries in your light saber.
Click to expand...
Click to collapse
As much as I enjoy a good Star Wars reference, this is a little off. I think it's more like learning to pilot a Speeder Bike before you figure out how to change the batteries in your light saber. We all know an Ewok can do it but just like the furball it's easy to go flying into a tree!
ccosby said:
go download a copy of Slackware Linux and install it in a VirtualBox machine. Break it. Fix it. Learn how you fixed it. Break it some more.
Click to expand...
Click to collapse
I'm not denying that is not a great way to learn, but unless you have a goal you're trying to accomplish it usually doesn't accomplish much. In my case I'd played with a copy of red hat years ago but without purpose so I didn't gain much. Recently I purchased a new router and loaded on a copy of DD-WRT. I had read about using it directly as a server (ftp/web/dlna) and even a bit torrent client. I wanted to use these features, so it took me a week of learning linux to get them installed. I broke the new features alot, but I didn't break my router.
So where am I going with this? I think perhaps instead of telling people to go out and learn it somewhere else, providing the answer and pitfalls to avoid would be more productive.
Like Benmeyers said.
I have had a couple different linux os's on my machine over the years, but they were only installed a very short while. I didn't see the "necessity" over windows.
Like Benmeyers said now I have a need for it. As many have pointed out, the busybox is not actually linux. What I need is to learn all of the busybox commands, which many have given me useful tips. Installing a while distribution of linux on my computer might just be overkill, and with root, I can do it just as well, after all.. it is like installing debian on my phone.
While I lived in Germany for 8 years, I HAD to learn to speak German, I went to a German Trade School because there were no American ones, and people at the one I went to did not speak English. My point is out of neccessity I had to learn it, and there were Germans who were proud that I was taking the time to learn THEIR language. I became very fluent because people took the time to help me. The ones that just laughed at me are the same ones that complained that the stinking Americans and other foreigners never bother to learn their language.
Anyway, thanx for all the help.

WM Programming-Pascal and C console programs

Hi everyone!
I'm studying Turbo Pascal and C programming languages at school,I write console programs from "add 2 numbers and print the result" to something more complex.
I was wondering...is there any way to get these simple console programs to work on my HTC Touch PRO 2 (WM 6.1)?
Hope you can help me...
Thanks!
I 2nd this, I'd like to know too.
Or otherwise I'm also interested in writing a basic app for WM just to try it.
Jason
easy to do with c using embedded visual c++ which you can google and it's free and c++ is always backward compatible with ansi c
doubt you will have much luck with pascal because the best bet would have been borlans options and they quit the whole market with their delphi pascal options
nailing the last nail in the coffin of pascal
For Pascal, use FreePascal/Lazarus combo. It's a ***** to set up, though.
Rudegar said:
easy to do with c using embedded visual c++ which you can google and it's free and c++ is always backward compatible with ansi c
doubt you will have much luck with pascal because the best bet would have been borlans options and they quit the whole market with their delphi pascal options
nailing the last nail in the coffin of pascal
Click to expand...
Click to collapse
Can I write console applications with it,or they have to have a GUI?
Chainfire said:
For Pascal, use FreePascal/Lazarus combo. It's a ***** to set up, though.
Click to expand...
Click to collapse
Yeah,i tried that,but i can't make it work...I followed the guide but i can't do anything that works on WM
"Can I write console applications with it,or they have to have a GUI?"
both a lot easier to make console apps though
Thank you,I'll give it a try
The problem you will encounter with console applications is the fact that there is no console as such.
printf() will not work as there is no output window on which to write anything. There is also no way of reading user input direct from the 'keyboard' or keypad.
When the exe is run it starts as a windowless application, the WinMain() function is called and when this ends it is terminated. You can open and close files, read and write to and from them, anything you like, as long as it requires no user input, and does not display anything. Pretty restrictive! The only thing the user will see is the hourglass/busy icon, until the app finishes.
Even C# console applications are subject to the same restrictions.
To do anything 'smart' it will have to be a PPC (GUI) application.
there are plenty of free console apps one can download for free
stephj said:
The problem you will encounter with console applications is the fact that there is no console as such.
printf() will not work as there is no output window on which to write anything. There is also no way of reading user input direct from the 'keyboard' or keypad.
When the exe is run it starts as a windowless application, the WinMain() function is called and when this ends it is terminated. You can open and close files, read and write to and from them, anything you like, as long as it requires no user input, and does not display anything. Pretty restrictive! The only thing the user will see is the hourglass/busy icon, until the app finishes.
Even C# console applications are subject to the same restrictions.
To do anything 'smart' it will have to be a PPC (GUI) application.
Click to expand...
Click to collapse
What if I use Pocket Console,or something like that? Would they run correctly?
Can't really say, as I haven't used them. The console stuff I have written, drags objects from over the net, then writes the data out in a format I can use to a file on the device. No user input required.
All I can suggest is to try the classic
printf("Hello World!\n")
and see what happens. Good Luck!
C programing
Hello,
yes, you can. Just use pocketdos. An emulator for DOS and you can use your simple compilers
Search for Pocketdos.com
xdawis said:
Hello,
yes, you can. Just use pocketdos. An emulator for DOS and you can use your simple compilers
Search for Pocketdos.com
Click to expand...
Click to collapse
Thank you! They work now! PocketDos is great!

How to use terminal?

I've read in a few threads which required the use of terminal/fast boot.
What exactly is this? Can anybody point me to a guide/tutorial on how to use it?
Thanks in advance!
P.S. - I am a newbie in playing around with the Android system.
bump bump bump
Terminal basically allows you to run certain commands directly on your device rather than having to be coupled to your pc.
Android Terminal Emulator
Description
This application lets you access your Android's built-in Linux command line shell. It emulates a Digital Equipment Corporation VT-100 terminal. You can use this application to run utility programs on your device.
What is this app good for?
This application lets you run Linux command line utilities on your Android phone. It is mostly useful for computer programmers. It might also be useful for people who want to explore the Linux internals of their Android phone.
Click to expand...
Click to collapse
Some Android basics - http://forum.xda-developers.com/showthread.php?t=619153
How to use ADB - http://forum.xda-developers.com/showthread.php?t=502010
Terminal commands - http://www.busybox.net/downloads/BusyBox.html

BotBrew Vim Installation

Hello folks,
So i discovered the wonders of the amazing application "BotBrew", which is basically BusyBox but supercharged to bring a pretty full featured GNU UNIX terminal session to any arm device.
That being said I managed to successfully install Vim on my device without a problem. Its seriously amazing! running vim on my androids terminal!! No emulation! No mounted Linux, nothing but running the real vim on from my android's linux kernel. Phenomenal.
But im curious, i know that has all the same support as vim on linux, including syntax highlighting, etc. But i cant seem to get the syntax highlighting to work. It may be just because my terminal has its colors set to white on black, and maybe its overriding the colors of the syntax highlighting, or maybe I may have just not enabled it or something?
Is there a key combination to enable syntax highlighting in vim? As well as auto-completion?
I know in linux this happens automatically when you save the file with ":w" to whatever file extension it will start the syntax highlighting for that programming language.
So any thoughts on this guys? Maybe a terminal that has basic colors without color schemes? Or a keyboard shortcut that may enable autocompletion and syntax highlighting?
Thanks for your time guys. And i highly recommend getting BotBrew if you have experience on a Linux/UNIX terminal. get vim installed and check out the unreal list of amazing applications you can install and get your new terminal package manager "opkg".
Really you wont regret it.
Oh and help them out and add your device to the supported devices list if it works.
Take care everyone.
Ill take a screenshot in a bit too
Sent from my SPH-D600 using xda premium

Categories

Resources