[Q] Porting an CLI app to Android. - Android Software Development

Hi XDA Dev's,
I have a program called words. It's a windows based, but ported to linux program which is able to function as an English to Latin and reversed dictionary.
The program has to be ran in the Terminal, cos it is command line interface based.
I thought since it is a program ran in the Terminal you should be able to run it in the Android Terminal, but that's just a theory.
Practically it doesn't work that way.
After untarring the app I entered ./words or su ./words but either won't work.
It gives me the following:
(I took the block from the internet so hope you see a block, not some kind of symbol: )
EL4: not found
4: not found
4: not found
: not found
./words: 5 Syntax error: "(" unexpected
So I think the Android Terminal reads differently cos it doesn't expect that character.
The question is: How can I port a linux CLI program to Android? And is this possible with the App Inventor from Google?

I don't really understand ypur question. If you would like to run a shell script try this
Code:
sh script.sh
Sent from my GT-I5700 using XDA App

Hmm sh gives me almost the same error.
But that's the thing, I have no clue what it is, there are a few files which are being used by the program. One of them is words, but it has no extension.

TT5555 said:
Hi XDA Dev's,
I have a program called words. It's a windows based, but ported to linux program which is able to function as an English to Latin and reversed dictionary.
The program has to be ran in the Terminal, cos it is command line interface based.
I thought since it is a program ran in the Terminal you should be able to run it in the Android Terminal, but that's just a theory.
Practically it doesn't work that way.
After untarring the app I entered ./words or su ./words but either won't work.
It gives me the following:
(I took the block from the internet so hope you see a block, not some kind of symbol: )
EL4: not found
4: not found
4: not found
: not found
./words: 5 Syntax error: "(" unexpected
So I think the Android Terminal reads differently cos it doesn't expect that character.
The question is: How can I port a linux CLI program to Android? And is this possible with the App Inventor from Google?
Click to expand...
Click to collapse
Hi, If you can get the source code to the program, then potentially the program can be ported to Android/ARM CPU architecture. The fact that it is a command-line program isnt such an issue - an Android app can be designed to interact with that (eg using Runtime.getRuntime().exec()).
If you just copied over the binary that runs ok under Linux on your PC, and tried to execute it on your Android device, it wont work. Your PC is running x86/x64 based CPU, your Android device is running ARM based CPU (eg you're putting diesel fuel into a car that needs petrol).
- jc

If I had the dictionary file, I could put it on my hosted site and write an app.

Rootstonian said:
If I had the dictionary file, I could put it on my hosted site and write an app.
Click to expand...
Click to collapse
You said it like it's that easy; but if you want I'd appreciate it.
The link on the official site doesn't work anymore so I uploaded the .tar.gz file on my website. Direct link:
http://www.freewebs.com/hoitom/words-1.97Ed-linux.tar.gz
Click to expand...
Click to collapse
I already made a concept of what it could look like with the App Inventor, but I don't mind else:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Note: this is only a English to Latin example. It has to be Latin to English too.
I hope you're able to do it. I'm really bad with linux.
Good luck

http://users.erols.com/whitaker/words.htm is the page for this program. It's written in ada and the author supplies the source. It will probably not be much harder than just compiling it for android once there is a working cross compiler, GNAT AUX is working on one currently http://www.dragonlace.net/posts/GNAT_AUX_ported_to_Android/.

Related

[PROGRAM] De-Captivated (One-click UNLOCK/ROOT/SIDELOADER/TETHER/MARKET ENABLER)

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
De-Captivated
I created this root and unlock combo modeled after the old iPhone jailbreaks which allowed you to unlock. Technically speaking this is not one click, but it is the single fastest way to do both. Right now it is only Mac, but it could come to PC eventually if I have time and find a tester. Remember, that if this application works I would really appreciate it if you donate.
It does the following:
Roots
Unlocks
Installs android-wifi-tether
Installs Market enabler
Sideloads
Required:
Mac
Samsung Captivate
Other carrier SIM card
How to use:
Just download the file from the link below or in the attachments:
Newest version
Now mount the DMG file and you should see this:
Drag the folder to the hard drive picture BUT NOTHING ELSE. Once the folder finishes copying just double click on the icon with the lock and run the program (it opens in a terminal window). It is VERY self explanatory from there and it includes step by step directions. I hope this program helps.
If you tried unlocking too many times:
It will then ask you for another code. Enter the unfreeze code that it gives you on the very last screen of the program. Enter that.
Donate:
This program took a long time to make and I would really appreciate it if you donate. Your donations will help me keep this program up-to-date. Currently I only accept PayPal donations at:
http://bit.ly/cplmLk
Credits:
NBS11 for this program and the mac unlock source
DaGentooBoy for the unlock meathod
Unfreeze code finder by RazvanG
Bowsa2511 for the code to extract unlock
Blackjackboy for root method
reserved if I need it later
Another great post Nbs! You certainly are a team player
I don't have access to a OS X system to test this, but when you have a Windows solution set-up, let me know for testing.
I don't get it, when I try to load this on my PC it doesn't do anything? J/k ;-P looks cool man, I hope it works as great as it looks! (I'm sure it is)
Clienterror said:
I don't get it, when I try to load this on my PC it doesn't do anything? J/k
Click to expand...
Click to collapse
Haha I thought you were serious for a minute. Yeah. Well for now its Mac only because PC's do not really handle shell scripts well. I will probably convert it later with the help of someone else but until then its mac only (and if you have linux you can get it to work if u change a few things)
I have added sideloading functionality to the app.
Platform independent solution!!
http://forum.xda-developers.com/showthread.php?t=751934
designgears said:
Platform independent solution!!
http://forum.xda-developers.com/showthread.php?t=751934
Click to expand...
Click to collapse
It doesn't unlock....
Sorry, I just got home from work.
I'm now looking at the files you sent me, you talking about the files inside the other folder (not the mac os one) right?
Bowsa2511 said:
Sorry, I just got home from work.
I'm now looking at the files you sent me, you talking about the files inside the other folder (not the mac os one) right?
Click to expand...
Click to collapse
I am assuming that is it. If there is a weird folder with basically nothing in it that is probably a folder that Mac OSX adds to everything that is hidden but shows up on windows.
What are the paths you want incorporated?
Sent from my SAMSUNG-SGH-I897 using XDA App
Bowsa2511 said:
What are the paths you want incorporated?
Sent from my SAMSUNG-SGH-I897 using XDA App
Click to expand...
Click to collapse
I am confused by what that means? I just want the paths converted to the windows equivlent (instead of / c:// etc.)
nbs11 said:
I am confused by what that means? I just want the paths converted to the windows equivlent (instead of / c:// etc.)
Click to expand...
Click to collapse
Oh, ok lol

[APP] Compiled lynx binary for android - Shell or ADB

I've searched the web, and found no lynx binaries for android, so I set out to compile it myself.
For the uninitiated, lynx is a text-based browser. No images, no javascript, no flash. Just pure content.
You can use it by connecting to your phone through adb, telnet, ssh or a shell on the phone itself.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This is lynx version 2.8.8 with ncurses 5.9
I pretty much just followed the instructions at http://www.embedu.org/Column/Column294.htm, and added a flag to make the linking static. No code changes were required.
Installation instructions
Root is not required.
You need to unzip the file on the /sdcard folder. The following files must exist:
/sdcard/lynx/lynx.cfg
/sdcard/lynx/lynx.lss
/sdcard/lynx/cache/
Then you need to move the binary to /data/local (or /system/xbin if you want something more permanent. Then you'd need root)
and run this command:
chmod 755 /data/local/lynx
Then run :
/data/local/lynx
and enjoy!
Additional information
If you want to put these files somewhere else, you must redefine the following variables, respectively:
LYNX_CFG (eg: export LYNX_CFG=/system/etc/lynx.cfg)
LYNX_LSS (eg: export LYNX_LSS =/system/etc/lynx.lss)
TMPDIR (eg: export TMPDIR =/cache)
If you receive an error message about the terminal, you need to configure a terminal.
Here are some instruction (for nano, but it works the same)
Sources are at the following addresses:
http://lynx.browser.org/
http://www.gnu.org/s/ncurses/
reserved
soon get the flash-able package
Thanks! I installed this on my ZTE Blade with 2.3.4 Gingerbread, but after setting everything in Terminal Emulator, I get these errors:
Alert!: Unable to connect to remote host.
Looking up lynx.isc.org
Unable to locate remote host lynx.isc.org.
lynx: Can't access startfile http://lynx.isc.org
Click to expand...
Click to collapse
As if there were no internet connection...
Awesome
Will be testing on my thunderbolt later today. I'll let you guys know how it goes.
However, would you mind reposting this on RW, or would you mind if I were to repost it and link back?
[EDIT] In having just configured everything, I also get the error from the post above. It seems as though lynx thinks it doesn't have internet access. This is the case on 3g and wireless networks. Let me know if you want me to test anything for you.[/EDIT]
All the best,
-HG
Looks great.
May I add that to my script ?
http://forum.xda-developers.com/showthread.php?t=1191984
Well, I was able to install it from a chrooted ubuntu 10.10 distro on my device. It's already compiled for ARM on ports.ubuntu.com, so maybe it's not so exclusive.
Sent from my Milestone 2 XDA App
Sure
sebsch1991 said:
Looks great.
May I add that to my script ?
http://forum.xda-developers.com/showthread.php?t=1191984
Click to expand...
Click to collapse
Sure, go ahead. It's open-sourced after all, I just built it.
dangpzanco said:
Well, I was able to install it from a chrooted ubuntu 10.10 distro on my device. It's already compiled for ARM on ports.ubuntu.com, so maybe it's not so exclusive.
Sent from my Milestone 2 XDA App
Click to expand...
Click to collapse
Nice. Can you point me to the correct file? I got as far as http://ports.ubuntu.com/pool/universe/l/lynx-cur/, but I don't know which one contains the binary.
While this is quite cool, why lynx? Why not elinks? It has much better layout capabilities. It has tabs! It even has javascript.
Code:
[email protected]:/# apt-get install lynx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
lynx
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/215kB of archives.
After this operation, 254kB of additional disk space will be used.
Selecting previously deselected package lynx.
(Reading database ... 66275 files and directories currently installed.)
Unpacking lynx (from .../lynx_2.8.8dev.2-1_all.deb) ...
I installed it that way.
Search for opkg (i think this is the name) if you are curious. It's a way of using deb packaging on Android (G1), but not in development anymore...
Sent from my Milestone 2 XDA App
I would be nice if someone could compile the HTTPS version of this so I could browse my banks mobile site
norti said:
Thanks! I installed this on my ZTE Blade with 2.3.4 Gingerbread, but after setting everything in Terminal Emulator, I get these errors:
As if there were no internet connection...
Click to expand...
Click to collapse
any solution ? i got the same problem...
hawkeyexp said:
any solution ? i got the same problem...
Click to expand...
Click to collapse
Can you ping any web address from the shell? What about wget, can you try that?
both pissble without problems
I am getting the following error
Looking up <url>.
Unable to locate remote host <url>
Alert!: Unable to connect to remote host.

[Q] [Solved] How to determine PATH for busybox binary location?

I'm hoping to be able to get some feedback and bounce this idea around. I wasn't able to figure out the right terms for a google search with good results even though I spent a while trying.
From an Android application, I want to determine where the busybox binary is installed on the system or data partition. I was hoping for a pure java solution, but I don't think there are any android java APIs for calling the shell PATH variable...
I also wanted to avoid hard coding the common linux binary directories (ex. /system/bin and /system/xbin, etc.)
From a shell perspective, I would usually run busybox find / -name busybox to locate it. Or I'd run busybox which busybox .. none of these are pure Android java solutions.
There are only two ways I'm aware of:
1) Using the linux binary "which". I could compile this for arm (or use the busybox applet) and package this binary into the application, have it extract when the application loads and execute and parse the output. Could do the same with the find linux binary...
2) Use the RootTools method Stericson published - InternalMethods.java. Although his approach uses a root shell to run dd to copy it from /init.rc (permissions usually read only for root) into /data/local/tmp and set it 777 so the android application and parse it for the export PATH line.
EDIT: found another method .. kind of an interesting approach.
http://osdir.com/ml/AndroidDevelopers/2009-03/msg04053.html
ps | grep /system/bin/sh
cat /proc/<pid>/environ
have to parse some of that output, but it seems to work thru adb shell w/o root.
I very well might have overlooked something or missed another approach. Any other ideas or other approaches?
Thanks in advance!
Include busybox with your app, no need to worry about its version
Couldn't you use java.lang.System.getenv()?
http://developer.android.com/reference/java/lang/System.html#getenv(java.lang.String)
doixanh said:
Include busybox with your app, no need to worry about its version
Click to expand...
Click to collapse
lol. unfortunately the scope of my app is only to show the user where their busybox binary is currently located, not provide them with a busybox binary.
Gene Poole said:
Couldn't you use java.lang.System.getenv()?
http://developer.android.com/reference/java/lang/System.html#getenv(java.lang.String)
Click to expand...
Click to collapse
Wow! very interesting. Sad I couldn't find this in all my searching through the android docs.
Two questions after looking over the information I can probably answer through testing, but can't test at the moment. If anybody knows the answer, would be helpful. Otherwise I'll post back when I am able to test.
1) Would the SecurityManager block a 3rd party app from using this call as it might be reserved for only apps signed with platform keys? I can compile and test watching logcat to see if it blocks this call.
2) For the getenv(String name) method, what value should be passed as the string? I can probably bypass this by just running the getenv w/o a string to have it return the Map and sort through the map.
Thanks for the help/suggestions/feedback!
Finally had a chance to test!
Gene Poole said:
Couldn't you use java.lang.System.getenv()?
http://developer.android.com/reference/java/lang/System.html#getenv(java.lang.String)
Click to expand...
Click to collapse
Turns out to be the perfect answer!!
This is the exact command I was looking for:
textBox.setText(System.getenv("PATH"));
Found a great test example for implementing real quick - How do I get Environment Variables?
Here is the output on my EVO 3D:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

[Win-Linux][11/15/11]{Tool} - AndroBox, Quick + Easy ADB And Debug Tools With GUI

AndroBox
Quick and Easy to use ADB and Debug tools for professionals and beginners
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
ADB and similar command line tools for Android have been a pain for new users to learn and extra work for the Developer while working.
Personally, I got sick of typing and having to remember things so I made this tool. It is also nice because it is mucho faster than I could do it!
I will be cleaning things up and making it look nicer (more even...?) as well as releasing the source code soon. Be patient!
DOWNLOAD - WINDOWS:
http://dl.dropbox.com/u/58849669/AndroBox-Win_0.4.zip
DOWNLOAD - LINUX:
http://dl.dropbox.com/u/58849669/AndroBox.linux.zip
UPDATES:
11/15/11 UPDATES
- Linux Version Added - runs on ALL Linux standard distros
- Linux version requires device to be hooked up and present or it will not go past the first screen
- Linux version shows real time activity in the Bash terminal!
- Linux version requires you to go through the true google agreement (keeps code distro kosher)
10/27/11
- FIXED Bug-report
- DDMS Runs natively (if you do not care about DDMS, download the old version here: http://www.multiupload.com/OQSF5U7QNH)
- No longer requires a device to be plugged in to start up. check test.txt
EVERYTHING RUNS FROM WITHIN THE APPLICATION FOLDER.
This was done simply because I like to be able to carry my tools on a small flash drive and not install anything.
There is no need to install the whole SDK to get access to a few key tools.
ALL OF THE PROGRAM FUNCTION OUTPUTS ARE TXT FILES THAT SAVE TO THE APP FOLDER
This just keeps things nice and tidy. You have everything right there to look over when you want to.
READ THE INSTRUCTIONS!
This will tell you how to use each function.
LEARN ADB
Allows new users to find out just how much fun (and Linux) is in there. Yay shell!
*** DONATIONS ARE NOT GOING TO MY POCKET, THEY WILL BE DISTRIBUTED TO THE EFF AND CYANOGEN WEBSITES FOR THEIR HARD WORK! ***
*I am not resposible if you mess up your device using this tool, please don't be stupid.*
QUESTIONS? Shoot me a PM or Email that is enclosed in the instructions
Looks like an awesome tool, but i need the Linux version
Its working, I just need to make sure it works on all of the major Linux Distros.
Regular Ubuntu 10.04 is being finicky. Kubuntu, Xubuntu, and RedHat are playing nicely.
I just want to make sure that it is good for all before release. It also autohandles your path so all you have to do is a "chmod +x AndroBox", then "./AndroBox" and you are good to go!
Thanks
Great tool, thanks a lot
Updated - everything should work GREAT now. DEBUG (DDMS) runs natively and FULLY!!!!!
If you do not care about DDMS, use the older version as it is MUCH smaller since it does not need the included library files.
Great !
Waiting for tool that workin with linuxmint
Sent from my E398-EM30-S5570
HEY GUYS - I HAVE A WORKING LINUX VERSION, BUT I NEED PEOPLE WHO WANT TO DO A PRIVATE BETA!
Kubuntu, Red Hat, and Xubuntu have been tested as working.
Send me a PM or post in this thread!
Now with working linux version!!!!!!!!!!!!!!!!!!!
Testing on all major linux distros without issue!!!!!
Added Dropbox Links because of the mess with most other filehosting services ATM.
How do i start the linux version up?
Do i need to use terminal or?

[TOOL][ADB][Windows]RAM-Hog Sniffer For Rooted Android Emulators

Given the case you feel your favorite Android emulator runs slowly, especially at a certain game, then you should remind that Android emulator's (AVD) performance mainly depends on correct setting of its
A: Android per app Heap Size granted
B: VM total RAM (read: Random Access Memory) allocated off host machine
Most emulators don't automatically take care of this, they are preset to standard values: it's on the user to correctly configure it.
User has to check and monitor for the RAM usage of an individual app/game on Android, has to check which app/game is eating the maximum RAM and affecting the performance.
Yes, for me one of the fundamental questions users ask (or at least, they should) is: how much memory is my program using? It may be a simple question, but with a virtual memory operating system like Android the answer is quite complex.
By default Android OS - a derivate of Linux OS - since ages comes with procrank tool, what in detail shows you some RAM metrics for an application as those are VSS, RRS, PPS and USS. So also Android OS provided by the various emulators should do it, too.
Installed Terminal Emulator app on some wellknown emulators and ran procrank. Experienced that on Android emulators like
BlueStacks 4 ( Android Nougat )
PROCRANK doesn't work at all, you get message: "error creating kernel interface -- does this kernel have pagemap?"
MEmu 6 ( Android Nougat )
PROCRANK doesn't exist - means isn't implemented at all
NOX 6 ( Android Nougat )
PROCRANK isn't working, you get message: library "libpagemap.so" not found
Genymotion 3 ( Android Nougat )
PROCRANK doesn't work at all, you get message: "error creating kernel interface -- does this kernel have pagemap?"
Maybe someone knows reasons for that?
Hence, to get out the app/game specific RAM metrics ( read: VmPeak, VmVSS, VmHWM, VmRSS and VmPSS ) on an Android emulator, I wrote a Windows command script ( ~50KB ) that running against a rooted emulator gives them to me: I named it RAM-hog Sniffer. Notes: It's provided on an "AS IS" basis, it's free software, and you are welcome to redistribute it under license GPLv3.
Successfully tried it on properly rooted and ADB-enabled BlueStacks v4.50.5.1003 ( Android Nougat ):
Excerpt of logfile created:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Useful or not is for you to tell, give it a try and leave a comment with suggestion if indicated.
Usage:
• Download the attached ZIP and unpack it on Windows PC into any location of your choice
• Connect a rooted and ADB enabled emulator to PC
• Run Windows batch-file named RAM-hog-Sniffer
FYI: You will need to install the Android ADB drivers if your emulator is not detected.
PS: Please, do NOT share this elsewhere - I want to be able to update if necessary.
Script revamped. New version is in OP.
gr8. ty
To keep you updated: BlueStacks announced to fix the PROCRANK problem
According to the description I think something good,
but, can the script, not to change to the installed system,
for editing on a computer.>?
Ciuma777 said:
According to the description I think something good,
but, can the script, not to change to the installed system,
for editing on a computer.>?
Click to expand...
Click to collapse
You use any ANSI-editor of your choice, preferredly of course Notepad++, to edit the script on your Windows computer according to your needs.

Categories

Resources