Using LINUX commands in App Inventor. Extension

18.- getprop

Gets an Android system property, or lists them all.

1 Like

thank you, this is powerful…
is this an update to the existing extension from here?
https://groups.google.com/d/msg/mitappinventortest/zzW_HW7WLXQ/nAAxHktJCwAJ

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

3 Likes

Great work @Juan_Antonio. Like @Taifun said. Really powerful.

1 Like

It is the same extension. This topic is only about its use.
Although in the next few days I will update it to be able to work with the asset files when the application is compiled, as @TIMAI2 proposed in a previous message.

1 Like

19.- grep

The grep is a filter that is used to search for lines matching a specified pattern and print the matching lines.
https://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/

grep “seis” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -r “seis” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -v -e “six” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -o -b “seven” /mnt/sdcard/AppInventor/assets/numeros.txt
grep -n “six” /mnt/sdcard/AppInventor/assets/numeros.txt


shell_grep.aia (11.5 KB)

2 Likes

20.- gunzip ::: gzip

gzip: zip and unzip
gunzip: unzip

gzip --help
gzip -k -c /mnt/sdcard/AppInventor/assets/numeros.txt > /mnt/sdcard/the_numeros.txt.gz

gzip -d -c /mnt/sdcard/the_numeros.txt.gz > /mnt/sdcard/los_numeros.txt


shell_gzip.aia (11.0 KB)

3 Likes

21.- head ::: tail

head -n 3 /mnt/sdcard/numeros.txt (shows the first three lines of the file)
tail -n 2 /mnt/sdcard/numeros.txt (shows the last two lines of the file)

1 Like

22.- ifconfig ::: ip ::: iw

ifconfig is used in LINUX to show/change network configuration,
but to modify the configuration you need to be root.

ifconfig wlan0 (shows IP)


ip net-tools which is used for performing several network administration tasks.

ip
ip address show wlan0
ip n show
ip neigh show
ip -s neigh
ip -neighbour (to view MAC address of the devices connected to your system.)

iw (similar to ip)

1 Like

23.- kill ::: killall

kill command sends a signal to a process, if signal is 9 (default) kill a procces.

ps (get PID of process)
kill 19260 (kill MIT Companion)

shell_kill2
shell_kill

killall edu.mit.appinventor.aicompanion3 (kill process by name)

3 Likes

24.- ln ::: logcat ::: logname

ln creates hard links by default, or symbolic links with -s ( –symbolic), it is a very important command in LINUX, but I cannot use it with AI2.

logcat -t 300 ( is a command -line tool that dumps a log of system messages)

logname (“name” user, example: u0_a173)

1 Like

25.- ls

list of files and directories.
https://www.thegeekdiary.com/basic-ls-command-examples-in-linux/

ls -ali /mnt/sdcard/

-a (all, hidden .files)
-l (long format)
-i (show i-node number)

ls -ali /mnt/sdcard/ | grep 4096 (filter with grep lines with number 4096 (size))
ls -ali /mnt/sdcard/DCIM/
ls -ali /mnt/sdcard/DCIM/Camera > /mnt/sdcard/list_my_photos.txt

1 Like

26.- md5sum

Similar to cksum

md5sum --help
md5sum /mnt/sdcard/numeros.txt
return
74c22f5af060ac90932f7354261d887b numeros.txt

27.- mkdir

Create directory.

mkdir /mnt/sdcard/my_new_directory
mkdir -p /mnt/sdcard/directory/subdirectory/subsubdirectory

1 Like

28.- mount

mount, shows where the devices are mounted.

To mount devices you need to be root #

29.- mv

mv, move a file or directory, also used to rename a file or directory.

mv /mnt/sdcard/numeros.txt /mnt/sdcard/new_numeros.txt

1 Like

30.- netstat

netstat, list out all the network (socket) connections.

netstat.

curl opens up possibilities in REST API calls.

2 Likes

31.- ping

ping, to check the network connectivity between host and server/host.

ping -c 3 google.com (sends 3 packets)
ping -c 3 192.168.1.1

32.- printf

printf prints a formatted string to the standard output.

printf “My name is “%s”.\nIt’s a pleasure to meet you.” “John”
printf “%d plus %5f %s %.*f.” 5 5.05 “equals” 3 10.05
printf ‘hello\nworld\n!’
Examples from:

33.- ps ::: pm

ps, list process.

ps --help
ps -A

oooooooooOOOooooooooo

pm, package manager
shell_package

pm list packages
pm list packages -f
pm list packages -s
pm list features
pm list packages --show-versioncode
https://adbshell.com/commands/adb-shell-pm-list-packages