Bash ping script file in android terminal - android

I have small code for ping in a loop:
#!/system/bin/sh
_count=0
_target="dns.google.com"
echo "target :: $_target"
while true;
do
_time="$(date +%H%M%S)"
_count=$((_count + 1))
echo "::::::::::::::::::LOOP"
echo "time :: $_time"
echo "counter :: $_count"
ping -w 1 -c 1 $_target >/dev/null 2>&1 &&
echo "$? ... is reachable" ||
echo "$? ... is down"
done
I'm calling this from android terminal (using SManager).
It should check host availability with a ping in a loop.
The problem is that I get a real response only for the first ping and all the others are bad (output):
$ /system/bin/sh /storage/emulated/0/pinger.sh
target :: dns.google.com
::::::::::::::::::LOOP
time :: 174912
counter :: 1
0 ... is reachable
::::::::::::::::::LOOP
time :: 174912
counter :: 2
1 ... is down
::::::::::::::::::LOOP
time :: 174913
counter :: 3
1 ... is down
::::::::::::::::::LOOP
time :: 174914
counter :: 4
1 ... is down
.
..
...etc.
What is the reason for this behavior?
Lukas
EDIT 2:
New script:
#!/system/bin/sh
_count=0
_target="dns.google.com"
echo "target :: $_target"
while true;
do
_time="$(date +%H%M%S)"
_count=$((_count + 1))
echo "::::::::::::::::::LOOP"
echo "time :: $_time"
echo "counter :: $_count"
ping -w 1 -c 1 $_target
done
Output:
$ /system/bin/sh /storage/emulated/0/pinger.sh
target :: dns.google.com
::::::::::::::::::LOOP
time :: 205444
counter :: 1
PING dns.google.com (8.8.4.4) 56(84) bytes of data.
64 bytes from dns.google (8.8.4.4): icmp_seq=1 ttl=64 time=7.40 ms
--- dns.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 7.404/7.404/7.404/0.000 ms
::::::::::::::::::LOOP
time :: 205445
counter :: 2
PING dns.google.com (8.8.4.4) 56(84) bytes of data.
--- dns.google.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms
::::::::::::::::::LOOP
time :: 205447
counter :: 3
PING dns.google.com (8.8.4.4) 56(84) bytes of data.
--- dns.google.com ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
.
..
...etc.

Related

Rebuild android code with error “SSL error when connecting to the Jack server. Try 'jack-diagnose”

System: ubuntu 18.04
environment:VirtualBox
The first time I compiled the AOSP source code on Ubuntu 18.04, it passed, and the second time I compiled it failed.
Here is an error message.
[ 10% 538/4980] Ensuring Jack server is installed and started
FAILED: setup-jack-server
/bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 4.11.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.32.CANDIDATE.jar 4.32.CANDIDATE || exit 47 )"
Jack server already installed in "/home/user/.jack-server"
Communication error with Jack server (35), try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'
SSL error when connecting to the Jack server. Try 'jack-diagnose'
[ 10% 541/4980] build out/target/product/rk3399_mid/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy
ninja: build stopped: subcommand failed.
22:32:18 ninja failed with: exit status 1
#### failed to build some targets (01:11 (mm:ss)) ####
Build android failed!
Generate error reports
/prebuilts/sdk/tools/report/18577$ unzip jack-report.18557.zip
Archive: jack-report.18557.zip
inflating: report.18557.txt
inflating: launcher.jar
inflating: config.properties
creating: logs/
inflating: logs/outputs.txt
inflating: logs/jack-server-0-2.log
inflating: logs/jack-server-1-0.log
inflating: logs/jack-server-0-0.log
extracting: logs/jack-server-0-0.log.lck
inflating: logs/jack-server-0-1.log
inflating: server-1.jar
creating: jack/
report.18557.txt :
ps -o "pid args" | grep com.android.jack.launcher.ServerLauncher | grep -v grep | awk '{print dump-report}' | xargs kill -3
$ id -u
1000
$ ps -A -o "uid pid args" | grep com.android.jack.launcher.ServerLauncher | grep -v grep
1000 6708 java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/zhangying/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
$ lsof -i TCP:8376 -l
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 6708 1000 21u IPv6 58493 0t0 TCP localhost:8376 (LISTEN)
$ lsof -i TCP:8377 -l
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 6708 1000 23u IPv6 58499 0t0 TCP localhost:8377 (LISTEN)
$ cat "$JACK_CLIENT_SETTING"
# Server settings
SERVER_HOST=localhost
SERVER_PORT_SERVICE=8376
SERVER_PORT_ADMIN=8377
# Internal, do not touch
SETTING_VERSION=4
$ cd "$JACK_HOME"; ls -l -R -n .
.:
total 10412
-rw------- 1 1000 1000 2097 May 2 10:04 client.jks
-rw------- 1 1000 1000 2814 May 2 21:48 client.pem
-rw------- 1 1000 1000 356 May 2 10:12 config.properties
drwxr-xr-x 2 1000 1000 4096 May 2 10:04 jack
-rw------- 1 1000 1000 5102506 May 2 10:04 launcher.jar
drwx------ 2 1000 1000 4096 May 2 21:48 logs
-rw------- 1 1000 1000 982 May 2 22:39 report.18557.txt
-rw------- 1 1000 1000 5522186 May 2 10:04 server-1.jar
-rw------- 1 1000 1000 2066 May 2 10:04 server.jks
-rw------- 1 1000 1000 1042 May 2 21:48 server.pem
./jack:
total 0
./logs:
total 32
-rw-r--r-- 1 1000 1000 689 May 2 22:03 jack-server-0-0.log
-rw-r--r-- 1 1000 1000 0 May 2 10:20 jack-server-0-0.log.lck
-rw-r--r-- 1 1000 1000 585 May 2 10:23 jack-server-0-1.log
-rw-r--r-- 1 1000 1000 689 May 2 10:19 jack-server-0-2.log
-rw-r--r-- 1 1000 1000 585 May 2 10:16 jack-server-1-0.log
-rw------- 1 1000 1000 13411 May 2 22:39 outputs.txt
$ curl --version
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
$ JACK_EXTRA_CURL_OPTIONS=-v jack-admin list server
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8377 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /home/zhangying/.jack-server/server.pem
CApath: /etc/ssl/certs
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:8377
* Closing connection 0
SSL error when connecting to the Jack server. Try 'jack-diagnose'
$ jack-admin server-stat
Getting statistic from background server
SSL error when connecting to the Jack server. Try 'jack-diagnose'
$ base64 --version
base64 (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Simon Josefsson.
$ (echo amFjaw==;echo LXNlcnZlcg==) | base64 --decode
I get the same error when I switch to Ubuntu 16.04.Below is a list of the installed Curl versions of Ubuntu 18.04.
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
curl/bionic-updates,bionic-security,now 7.58.0-2ubuntu3.13 amd64 [installed]
libcurl3-gnutls/bionic-updates,bionic-security,now 7.58.0-2ubuntu3.13 amd64 [installed,automatic]
libcurl4/bionic-updates,bionic-security,now 7.58.0-2ubuntu3.13 amd64 [installed,automatic]
libcurl4-openssl-dev/bionic-updates,bionic-security,now 7.58.0-2ubuntu3.13 amd64 [installed]
I have tried many ways, but I can't solve it. Please help me,thanks.
After the two steps below were applied, the AOSP was successfully built.
Remove TLSv1, TLSv1.1 from jdk.tls.disabledAlgorithms in /etc/java-8-openjdk/security/java.security file
Restart the jack server:
cd /prebuilts/sdk/tools/
./jack-admin kill-server
./jack-admin start-server
I just found the answer, see the link below
enter link description here
Change the code to this,
from /etc/java-8-openjdk/security/java.security remove TLSv1, TLSv1.1.
jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA,
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL,
include jdk.disabled.namedCurves
I just want to give all the different ways to solve the problem.
There are few ways to overcome this problem, one may work for someone -
Try to simply restart the jack server by below command at your android root folder
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server
Try to reduce the number of concurrent services in file $HOME/.jack-server/config.properties
Code:
jack.server.max-service=4
Try to make this value 2 or 1.
If jack server is not running or it hangs when try to run. Than try removing TLSv1, TLSv1.1 from rom /etc/java-8-openjdk/security/java.security
Solution 3 Worked for me.
A way to fix that in your Dockerfile :
USER root
# Fix jack server SSL issue during build
RUN perl -0777 -i -p -e 's/(jdk.tls.disabledAlgorithms=.*?), TLSv1, TLSv1\.1/$1/g' \
/etc/java-8-openjdk/security/java.security

How to parse "adb shell top" to display only CPU or memory usage?

I have the output result from "adb shell top" in a .txt file. I want to get only the CPU usage for my testing app and display it as a table:
Time cpu %
1 18
2 20
3 15
4 19
I have tried cat top.txt | grep Cpu | nl > cpu.txt (followed the instructions from here link), but the file is empty.
Do you have any idea how can I start? I have never used regex and not sure will it help. Please, looking forward hearing any tips :)
User 23%, System 5%, IOW 0%, IRQ 0%
User 434 + Nice 0 + Sys 106 + Idle 1273 + IOW 10 + IRQ 0 + SIRQ 3 = 1826
PID PR CPU% S #THR VSS RSS PCY UID Name
1868 1 20% S 50 1394620K 175176K fg u0_a174 com.test.app
1841 6 2% S 11 1897824K 48632K fg shell uiautomator
4794 1 1% S 148 2334708K 130924K fg system system_server
447 1 1% S 14 422152K 17476K fg system /system/bin/surfaceflinger
29195 1 1% S 21 369676K 20040K fg media
Given your top.txt sample, I would do the following, step by step:
First, select only the lines for your app com.test.app with grep:
grep com.test.app top.txt
Take the third field (delimited by spaces, so this is the CPU usage) by piping into awk:
grep com.test.app top.txt | awk '{ print $3; }'
Add line numbering by piping into nl (the -nln is for left justification):
grep com.test.app top.txt | awk '{ print $3; }' | nl -nln
Finally, just prepend your header with echo (-e and double quotes are needed for newline \n):
echo -e "Time cpu %\n" && grep com.test.app top.txt | awk '{ print $3; }' | nl -nln
This will give you for the sample top.txt:
Time cpu %
1 20%

Jack server failed to (re)start

I am trying a build of Android N, but I am constantly getting this error :
15:37:13 FAILED: /bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 4.8.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )"
15:37:13 Jack server already installed in "/srv/jenkins/.jack-server"
15:37:13 Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /srv/jenkins/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
15:37:13 Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log
15:37:13 No Jack server running. Try 'jack-admin start-server'
15:37:13 No Jack server running. Try 'jack-admin start-server'
I put some logs in the jack-admin code and I am getting the following error, when I do ./jack-admin start-server.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to 127.0.0.1 port 8077: No route to host
isServerRunning : Curl code : 7
Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /srv/jenkins/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to 127.0.0.1 port 8077: No route to host
waitServerStarted : curl code : 7
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to 127.0.0.1 port 8077: No route to host
waitServerStarted : curl code : 7
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to 127.0.0.1 port 8077: No route to host
Can someone please help?
EDIT
Jack server logs are clean, there are no exceptions or errors.
The default ports 8076 and 8077 get blocked as seen in netstat -nlp, which indicates the server is indeed started.
tcp6 0 0 127.0.0.1:8076 :::* LISTEN 19180/java
tcp6 0 0 127.0.0.1:8077 :::* LISTEN 19180/java
The machine I am building the code upon, is behind a proxy.
When I was getting Curl error 7 it was accompanied by an SSL error when running jack-diagnose. The following solution worked for me:
Edit java.security file under /etc/java-8-openjdk/security/
Remove TLSv1, TLSv1.1 from jdk.tls.disabledAlgorithms
Restart the jack server:
cd <your-aosp-home-dir>/prebuilts/sdk/tools/
./jack-admin kill-server
./jack-admin start-server
Try changing service and admin ports both in .jack-settings and .jack-server/config.properties and make sure they match.
Jack server may not be able to use the default ports, especially if you are on a server machine where there are more than one user trying to use Jack.

Command giving no output when being read?

I have a rather weird issue. I can't figure out why it's happening or how to fix it.
The script:
#!system/bin/sh
#set -x
reader() {
t2=-1
grep -v -E "add device|name:" | while IFS=' ' read -r t1 a b c d _; do
t1=${t1%%-*}
t=`expr $t1 - $t2`
if let 't > 0 && t2 > -1'; then
echo "sleep $t"
fi
printf 'sendevent %s' "${a%?}"
printf '%5d %5d %5d\n' "0x$b" "0x$c" "0x$d"
t2=$t1
done
}
let() {
IFS=, command eval [ '$(($*))' -ne 0 ]
}
countDown() {
echo 'Starting in...'
i=4
while [[ $i -gt 1 ]]; do
i=$(($i-1))
echo "$i"
sleep 1
done
printf '%s\n\n\n' 'Go!'
# echo "$*"
"$#" | reader
}
clear
printf '%s >' 'Catch by [n]umber of events or [t]imeout?'
read type
case $type in
n)
printf '%s >' 'Events to catch?'
read arg
echo "Gonna catch $arg events!"
countDown getevent -t -c "$arg"
;;
t)
printf '%s >' 'Timeout (in seconds)?'
read arg
echo "Gonna catch events for $arg seconds!"
countDown timeout -t $arg getevent -t
esac
The goal of the script:
Catch the user's interactions (e.g. key presses, screen taps, etc) using the getevent command and outputs a script to stdout, that can be used to replicate these events.
Additional info:
getevent's output is in hexadecimal format
sendevent accepts decimal format
Expected output:
Catch by [n]umber or by [t]imeout? n
Events to catch? > 4
Gonna catch 4 events...
Starting in...
3
2
1
Go!
sendevent /dev/input/event5 1 102 1
sendevent /dev/input/event5 0 0 0
sleep 3
sendevent /dev/input/event5 1 102 0
sendevent /dev/input/event5 0 0 0
The problem:
The code runs as expected when "n" is picked. When "t" is picked, the script exits after the specified amount of seconds. However, it does not output anything - the first line of the while loop doesn't even run.
With set -x, here's what's shown (last few lines):
+ printf %s\n\n\n Go!
Go!
+ reader
+ t2=-1
+ grep -v -E add device|name:
+ timeout -t 5 getevent -t
+ IFS = read -r t1 a b c d _
Running this alone shows output to stdout (output that's supposed to be read and modified inside the while loop):
timeout -t 5 getevent -t
Any ideas?
Thanks.
EDIT:
Alright, so I think it's a buffering issue. Basically this gives a similar issue:
getevent > output
The file gets updated every bunch of events, but not instantly (and might never update if not enough events are made). I'm not aware of any work around on Android.
I think there's no way of enabling line-buffering in busybox's grep, but you can do something like this:
$ adb shell timeout -t 10 getevent -t | \
grep --line-buffered -v -E "add device|name:" | \
while read line; do echo "READ: $line"; done
Here was basically that stuff I translated from your code before being mangled by bug workarounds. Replacing the one command I don't have with cat on the timeout branch, it runs correctly with your sample input in Busybox sh, dash, mksh, bash, and ksh93.
Since so many basic things about the shell and applications are broken, it isn't surprising this doesn't work. I would make sure Busybox is up-to-date and see whether the arithmetic and other bugs you keep hitting are reproducible on other systems, and report bugs if this code doesn't work.
#!/bin/sh
reader() {
t2=-1
grep -vE '^(add device|[[:space:]]+name:)' |
while IFS=' ' read -r t1 a b c d _; do
let "(t = (t1 = ${t1%%-*}) - t2) > 0 && t2 > -1" && echo "sleep $t"
printf 'sendevent %s' "${a%[[:digit:]]:}"
printf '%5d %5d %5d\n' "0x$b" "0x$c" "0x$d"
let t2=t1
done
}
let() {
IFS=, command eval test '$(($*))' -ne 0
}
countDown() {
echo 'Starting in...'
i=4
while let 'i-=1 > 0'; do
echo "$i"
sleep 1
done
printf '%s\n\n\n' 'Go!'
echo "$*"
"$#" <&3 | reader
}
isDigit() {
while ! ${1+false}; do
case $1 in
*[^[:digit:]]*|'') return 1
esac
command shift
done 2>/dev/null
}
main() {
printf '%s >' 'Catch by [n]umber of events or [t]imeout?'
read type
case $type in
n)
printf '%s >' 'Events to catch?'
read arg
isDigit "$arg" || return 1
echo "Gonna catch $arg events!"
countDown getevent -t -c "$arg"
;;
t)
printf '%s >' 'Timeout (in seconds)?'
read arg
isDigit "$arg" || return 1
echo "Gonna catch events for $arg seconds!"
countDown busybox timeout -t "$arg" cat -
;;
*)
return 1
esac
}
main "$#" 4<&0 <<\EOF 3<&0 <&4 4<&-
add device 1: /dev/input/event8
name: "bcm_headset"
add device 2: /dev/input/event7
name: "max8986_ponkey"
add device 3: /dev/input/event6
name: "sec_touchscreen"
add device 4: /dev/input/event5
name: "sec_keypad"
add device 5: /dev/input/event4
name: "orientation"
add device 6: /dev/input/event3
name: "accelerometer"
add device 7: /dev/input/event0
name: "proximity_sensor"
add device 8: /dev/input/event2
name: "geomagnetic_raw"
add device 9: /dev/input/event1
name: "geomagnetic"
45534-48646 /dev/input/event6: 0001 008b 00000001
45534-48646 /dev/input/event6: 0000 0000 00000000
45534-48646 /dev/input/event6: 0001 008b 00000000
45534-48646 /dev/input/event6: 0000 0000 00000000
EOF
# vim: set fenc=utf-8 ff=unix ft=sh :
Output:
$ bb --help
BusyBox v1.21.0 (2013-02-20 20:39:21 CST) multi-call binary.
Usage: bb [-/+OPTIONS] [-/+o OPT]... [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]]
Unix shell interpreter
$ bb answers/countdown
Catch by [n]umber of events or [t]imeout? >t
Timeout (in seconds)? >5
Gonna catch events for 5 seconds!
Starting in...
3
2
1
Go!
busybox timeout -t 5 cat -
sendevent /dev/input/event6: 1 139 1
sendevent /dev/input/event6: 0 0 0
sendevent /dev/input/event6: 1 139 0
sendevent /dev/input/event6: 0 0 0
Had the same problem, and remembered a trick that I first used in MS-DOS 3.30, and later in Cygwin(not for timeout, but the more command is a magical bullet for lots of redirect problems):
timeout -t 8 getevent | more > getevent.txt
works well in Total Commander's shell
with su (not sh)
You're welcome :-)

how do i get rid of the bugs (what is wrong with my script )

i have written a bash script that uses nice, renice and oom priority(optional ), to bulletproof apps periodically, it check for the app if running renices it else, nices it for the next time running, but there are bugs and because I am new to bash scripting I needed some help, this is for a sony ericsson xperia x10 running gingerbread, but other than the app names, all the commands are standard busybox commands
#!/system/bin/sh
#prioritizer script version 2
while true
do
phoneid='pidof com.android.phone';
if[ $phoneid ]
then
renice -17 $phoneid ;
#/system/xbin/echo "-17" > /proc/$phoneid/oom_adj;
else
nice --17 'com.android.phone' ;
fi
hid='pidof com.sonyericsson.home';
if[ $hid ]
then
renice -18 $hid ;
#/system/xbin/echo "-18" > /proc/$hid/oom_adj;
else
nice --17 'com.sonyericsson.home' ;
fi
supid='pidof com.noshufou.android.su';
if[ $supid ]
then
renice -17 $supid ;
#/system/xbin/echo "-17" > /proc/$supid/oom_adj;
else
nice --17 'com.noshufou.android.su';
fi
renice -17 'pidof com.android.mms'
renice -14 'pidof com.sonyericsson.music'
renice -17 'pidof android.process.media'
renice -16 'pidof mediaserver'
renice 5 'pidof com.google.process.gapps'
renice 5 'pidof com.Google.android.apps.uploader '
sleep 1000
done
exit 0
if you can find the error or show me a good scripting guide i will be thankful
In a shell there is no such statement as if[. You need a space after each if.
Also, after:
phoneid='pidof com.android.phone'
you have in your variable text: "pidof com.android.phone" instead of output of that command. You need to use `command param ...` or (preferably) $(command param ...) syntax.
Remember to check you shell syntax with:
/bin/sh -n myscript.sh
The command above (run on your PC) will not try to run the script, just check the syntax.
Also, You have a lot of uneeded semicolons, but this will not fail your script.

Categories

Resources