Basic commands for android!!

Hi,

I have a n android phone and just rooted it. I access it using 'terminal Emulator'. I performed many basic linux-like commands in the terminal like rm,ls,df,reboot etc and they are working fine. But many of them are not like man <something>, clear,du etc.

Can any of you please help to tell me alternatives for 'clear' and 'man' for android?:confused:

Hi...

I have just installed CygWin for the first time on my old Windwoes box and that didn't have clear either, so I quickly hacked this simple shell script and saved it in /usr/bin as clear...

#!/bin/bash --posix
# 'clear' command.
for n in {0..127}
do
        printf "\n"
done
printf "\x1B[1;1f"

Hopefully it will work for you with your version of shell. If not just experiment...
Don't forget to set the permissions as 755 or something similar and just launch it as the clear command...

Hope this is useful...

You can probably just type Control-L.

Regards,
Alister

What about

printf "\033[2J"

(man console_codes)

Hi RudiC...

Sadly that does not work on this Apple OSX 10.7.5...

It does NOT reset the cursor back to the top left hand side (plus prompt)...

EDIT:

This is a better bet:-

printf "\x1B[2J\x1B[1;1f"

Android phones do not have "man pages" per se included with the Android distribution on a mobile phone ....

Thanks everyone for replying!!!

I am not able to even use 'vi', how do I now create file and save in /usr/bin. My phone is Xperia neo v mt 15i. :confused:

echo is working. Print & printf are not working.

You might be limited to /bin/ed instead...

Good kuck...

For "printf" use "echo -e -n" instead, but I suspect you already know that... ;o)

1 Like

Thanks Wisecracker!!

echo -e -n "\033[2J" cleared the screen but it didn't take the cursor to top left.

echo -e -n "\x1B[2J\x1B[1;1f" did not work for me.

/bin/ed - I treid earlier also but it did not work.

To create a file you may abuse cat but it does not offer any editor functionality (cursormovment,...). Without a file as argument cat takes stdin as source.
Redirect its output to the new file.

cat >new_file_name

Edit: When you are finished typing your text press <ctrl>+d or <ctrl>+c to stop.

Try:-

echo -e -n "\x1B[2J\x1B[1;1H"

Maybe you terminal does not recognise "f"...

As for the editor I am at a loss except write your code on another *NIX like machine and use your email to obtain it is an attachment to an email...

I believe Busybox is available for Android. If so, that's probably an easy way to fill in most missing utilities.

Regards,
Alister

---------- Post updated at 10:47 AM ---------- Previous update was at 10:40 AM ----------

Regarding clear , that's usually a hardlink to, or a script which calls, tput . In the Linux world, those tools are part of ncurses . I would be surprised if it isn't also available for Android, since a lot of tools depend on it.

Regards,
Alister

One of the first things many do with a rooted phone is install sshd so they can login with any ssh client and get a real shell (edited by neo)

cat > file_name worked for me. I am surprised why I did not try it earlier. Thanks Cero. :b:

saved echo -e -n "\033[2J" in my /system/bin file as 'clear'. Its working now but same problem remains. Cursor doesn't go to top left of the screen.

Wisecracker : echo -e -n "\x1B[2J\x1B[1;1H" did not work either.:rolleyes:

Try

echo -en "\033[2J\033[1;1H

To shift the cursor to (H)ome you could try manually first to see if this works:-

echo -n $'\x1B[H'

If not then you might have to juggle the vertical tabs or cursor position using similar methods as before see here:-

ANSI escape code - Wikipedia, the free encyclopedia

EDIT:
An example:-

echo -n $'\x1B[2J'$'\x1B[24A'

This works on the very limited OSX 10.7.5 "/bin/echo" command too...

1 Like

You do not have a real terminal... (edited by neo). There's entire categories of things it cannot or will not do. Most people, once they root a machine, install sshd so they can login with a real terminal and do real things.

Thanks Corona.

I installed BusyBox and thereafter I am able to access 'clear', 'vi' etc commands.

I also installed sshd server and client. Accessed my cell through my laptop using ssh also connected to my Database server through mobile.

thanks Everyone!! :slight_smile:

Just wondering through the forum and find this good one so wanted to like the discussion.
It was very useful visit for me...
Keep it up......

Welcome to the family.:):slight_smile:

Certainly, It is one of the best forums.:b:

1 Like