LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Mobile (https://www.linuxquestions.org/questions/linux-mobile-81/)
-   -   grep not found (https://www.linuxquestions.org/questions/linux-mobile-81/grep-not-found-4175454490/)

rng 03-18-2013 02:42 AM

grep not found
 
I have superpad3 with android 2.2 which I have rooted with z4root app. It has also installed busybox. I installed terminal but when I try to run grep there is an error 'not found'. Same error occurs with many other commands also like uname and whoami. How can I correct this? Thanks for your help.

rtmistler 03-18-2013 02:53 PM

Busybox may not have been built to include those commands. One of the things about Busybox is that you build it to suit what you need, therefore you can build in or out certain shell commands. And by that you contain the size of Busybox which was intended to provide for memory limited systems rather than be a substitute for real binaries in your shell. And another reason is so that they can restrict what you can do if you get a shell so that it's less likely for you to be able to mess up the system.

If you can find binary versions of these commands compiled for the target processor and Linux version that tablet is using, then you can put those binaries on there and run them, providing the libraries are also on there.

The other alternative is to get the sources and build them on that tablet; however you may not have gcc and the like on there either.

Sorry, I haven't looked into working with the Linux that's on a tablet.

Here's a link discussing the commands by the way, I had forgotten that you can just type Busybox and it gives you the commands available:

http://<br /> http://www.droidforum...oid.html<br />

Another quick search helped me find this one which has a lot about installing a shell or even Ubuntu onto your tablet:

http://<br /> http://www.freeyouran...ndex.php<br />

And it would make sense that as you look deeper, you'd find a way to build an entire Android distribution, or be able to recompile the distribution on your tablet. There's got to be a way to:

- obtain the source for the distribution running on your tablet; i.e. Jellybean for ARM<blah-blah>
- build that into a kernel
- install that onto a tablet

Otherwise, how would these things then boot up for starters, right? I'd recommend searching Android "OS" development forums. Because most of the Android developers forums are going to concentrate on applications to run within the OS.

iqbal51 03-19-2013 12:41 PM

I am suffering the same problem. It is very important for us. Thanks for the sharing.

rtmistler 03-19-2013 01:19 PM

I may be incorrectly giving a history of Busybox. My experiences are with embedded development. Back in the day, when you compiled Linux for something like a Power PC or earlier ARM processors, the targets were completely custom and we really had to construct each kernel to be sized and optioned for the specific target. We also had limitations in dynamic memory (RAM), or NVRAM (what one considers to be disk space).

The command limitations were because if we did allow a console, we did not want to allow some smartypants to re-option or invalidate security on a half million dollar telephone switch, or router, merely because they were able to power cycle it and stick a hairpin in somewhere. And some of that stuff could not be allowed, otherwise you'd have very unreliable networking. We're talking about that 99.999% availability type of stuff.

Over time, the size allowances for RAM and the various ways to store data in non-volatile form have grown well enough that these days one is more "playing" when they say stuff like they managed to get Linux running on some 8-bit CPU with 8K of RAM. There's little or no product need for that, it's more hobbyist. The products want Bluetooth, WIFI, Networking, Graphics, they all have to mate with a mobile phone, and have to have a webserver.

I'm surprised a bit that Busybox is on Android.

Because when we evolved slowly to having less worry over space, however still had Busybox, we slowly usurped Busybox by saying, "Hmmm ... no 'ls' command ... copy the binary to /bin ...done!" Eventually we conned onto the fact that we had zero use for Busybox and in fact when we were writing more advanced shell scripts one of the engineers said, "Hey, what's wrong with grep?!? It doesn't work correctly!" And it was because the Busybox representation of grep was so old that it didn't match grep's functionality which the script writer was expecting to use. We told him how to usurp that command and within a release or two, that engineer removed Busybox completely because they didn't want to get bit again. Nobody complained because there was no need, someone else did the 2 hours worth of work and there was never any concern that a command was missing or not. He even set up the man path, something which we silently tolerated for years and merely typed man from a real Linux shell. It's just simply easier to do that on your target when you're developing on the target. However if the target is all limited because you had to cut it way back for size, then you couldn't.

Sorry for the length, but my point is that size-wise, chip-wise, Android doesn't have that problem, and clearly there are full ARM distributions of Linux. I wonder again why they use it, but that's not the point of this forum, or question.

rng 03-19-2013 08:24 PM

The command 'busybox grep <options> file' works. But it is a long command to write every time. I tried to make a script file and used 'busybox chmod +x script.sh' to make it executable, but it does not run. The error is "permission denied". This occurs even if I am root.

How can I run grep as a standalone command and how can I run script files on android?

rtmistler 03-20-2013 02:52 PM

Try:

Quote:

alias grep='busybox grep'

rng 03-20-2013 07:43 PM

How can I make this persist after rebooting on android?

rtmistler 03-21-2013 08:03 AM

If there's a .bash_profile then place it in there.

business_kid 03-22-2013 05:15 AM

I'm rooted and on Cyanogenmod-6.0 and grep is in /system/xbin
Quote:

su
which grep
If a command isn't found, treat it as a permissions error. Android 'neutered' busybox, removing things like su. Cyanogenmod and other mods restore them.

wargear 04-13-2013 10:19 AM

Is your busybox the latest build? rooted galaxy Note2 Note 10.1 tablet both have grep as well the other cmds you mentioned.. 2.2 is ancient news and may or may not be the issue... are you able to upgrade without losing root? (Had an asus TF300T tablet with s/n problem couldn't unlock bootloader but was able to root until 4.1. JB came out...)

ritu3356 04-22-2013 06:52 AM

Hi friend thanks for sharing this info it's great..


All times are GMT -5. The time now is 04:09 AM.