Using LINUX commands in App Inventor. Extension

44.- uptime

uptime, how long your system has been running.

45.- uudecode ::: uuencode

https://lowfatlinux.com/linux-uuencode-uudecode.html

base64 vs uuencode;

46.- wc

wc, count lines, words and characters.

wc /mnt/sdcard/my_file.txt
wc -l /mnt/sdcard/my_file.txt
wc -w /mnt/sdcard/my_file.txt
wc -c /mnt/sdcard/my_file.txt
wc -m /mnt/sdcard/my_file.txt

47.- zcat ::: zip_utils

zcat, like gzip -dc
zip_utils, tool zip.

48.- sh

sh, run script.

Simple example of script:

mkdir /mnt/sdcard/my_directory
DIRE="/mnt/sdcard/my_directory"

date >  $DIRE/date.txt
echo “Hello friend” > $DIRE/friend.txt
ping -c 3 google.com > $DIRE/my_ping.txt &
find /mnt/sdcard/ -name *.jpg > $DIRE/my_list_jpg.txt &
echo "Characters in file friend.txt: " > $DIRE/size_file.txt
wc -c $DIRE/friend.txt  >> $DIRE/size_file.txt

This script creates the directory: my_directory in SdCard and various files within it.

We can run it from the MITCOMPANION or Compiled.

Compiled: the block AssetsToCacheDir copies the file my_script.txt
from the assets to the cache directory of the same application, that is: /data/user/0/appinventor.ai_juan.shell_script/cachemy_script.txt

shell_script.aia (10.3 KB)

49.- awk

awk is a scripting language which is used for processing or analyzing text files .
We are going to do the examples in this tutorial:
https://www.linuxtechi.com/awk-command-tutorial-with-examples/

shell_awk.aia (12.1 KB)

1 Like

If you have sqlite3 in your /system/bin, you can run sqlite commands. Here are a couple of examples:

  1. Return the contents of a database table or view as a csv format text:

sqlite3 -header -csv /storage/emulated/0/< path/to/database > 'SELECT * FROM < table or view >;'

(remove "-header" if you do not want the column headings, replace items in and including <> for your database and table or view)

  1. Export the contents of a table or view to a csv file:

sqlite3 -header -csv /storage/emulated/0/< path/to/database > 'SELECT * from < table or view >;' > /storage/emulated/0/< path/to/filename >.csv

(this method is not provided by the various sqlite extensions, so a shortcut to extracting data)

I tried doing this with bash scripts but they just didn't want to work for some reason

2 Likes

Good One
How can I connect to a Redis server?
Will you please give me a sample string to connect and get the value?

You would need to have redis-tools installed on the device to even try to connect to a redis server using redis-cli and this extension. You cannot, as far as I know, install redis-tools....

1 Like

How can I Install it? Any link or idea?

1 Like

Sir, I already have a Redis server installed and it contains 7 ports. I have used the Cloud DB components and created all my apps. I want t to use the HSET, HGET commands of Redis as we don’t have in the Cloud DB component. So, I thought some how we have an option to release commands with this extension.

As I said....

You might be able to do something with php, sending commands to a server, and then use shell_exec to send redis commnds?

Please give me a syntax

https://www.php.net/manual/en/function.shell-exec.php

1 Like

I didn't get anything with this command (Firefox, Chrome, Win 7 pro, Galaxy Note8 - Android 9, Nexus5x - Android 8.1). Nothing from curl --version, curl --help etc.
Any clue why?

Probably not installed on your device (it isn't on mine either....)
Check what is with:

ls /system/bin/
1 Like

Yes curl is not there and also some other commands that I'm missing. So what to do?
Does it depend on my adb.exe (I have no clue of that)?

No it is just about the device and what was installed as default by the phone provider.
Worth having a look in some of your other devices?
Need to be rooted to be able to install other packages to the busybox

1 Like

Really useful extension, @Juan_Antonio!

Can we get ping result like this?