Shell script doesn't show any output until used "exit" - General Questions and Answers

Hello
I had created a shell script for myself (just a trial lol) to extract the boot image from system. the script goes somewhat like this:
#!/system/bin/sh
#getting superuser rights with su command
su
#checking if we have su permission or not
if [ "$UID" -eq 0 ]
then
echo "you have root so you can easily backup boot image"
sleep 2
else
echo "you don't have root so you can't backup boot image using this script"
fi
#going to root directory for easy access to internal storage
cd /
#changing directory to internal storage to create folder for backup
cd sdcard
#creating folder for backup
mkdir ImageBackup
cd ImageBackup
mkdir Boot
#finally using dd command to get boot image from system
dd if=/dev/block/by-name/boot of=/sdcard/ImageBackup/Boot/boot.img
cd Boot
ls
echo "Your Boot image has been succesfully backed up and is stored in ImageBackup/Boot in your internal storage"
Click to expand...
Click to collapse
i use adb shell and then "su" command to run the script, its located in /data/local/tmp and i run it using "./boot" ("boot" is the file name). i dont get any output. as soon as i type "exit" the script starts running (screenshot attached).
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

Code:
adb shell
opens an Android Terminal session - wherein shell commands like su can get applied - what finally gets closed with
Code:
exit
Take note that applying su doesn't output anything if processing it was successfull.

xXx yYy said:
Code:
adb shell
opens an Android Terminal session - wherein shell commands like su can get applied - what finally gets closed with
Code:
exit
Take note that applying su doesn't output anything if processing it was successfull.
Click to expand...
Click to collapse
I know that using commands like "su" dont give any output. Im telling that when i use "./boot" i.e. run the script, the script wont run until i use "exit" command. See in the screenshot

Again:
As soon as you execute adb shell in a Windows batch script without passing any arguments, a remote terminal session is opened in Android, which has to be closed with exit to continue with the next statement in the batch script.
In your case you have to code
Code:
adb shell "su"
instead of
Code:
adb shell
su
exit
what is senseless crap, IMO, because it simply opens a terminal session, establishes within this an elevated user ( AKA root ) and then immmediately closes this terminal session.

Related

Cherry Mobile W900 Dragon Phone

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Introducing (belatedly) this ...
It's a basically the SK Wynn S150 phone.
There are some work done on customizing in various Chinese and Brazilian forums most notably a CWM port but it seems to end there, and no updates.
Hopefully we can compile some more development for this mobile, especially now there was a huge price drop in our area for it which should mean a lot more of these are floating around waiting for a community development (in English please thank you!).
Most interest to me is rooting, which is at present accomplished using the mentioned CWM recovery option. This puts a quite outdated su binary and quite useless Superuser.apk into the phone giving it basic root functions but no prompts at all, and incorrect UID for root.
With some trial and error I was able to accomplish updating the su and Superuser.apk using existing tools and procedures already used in other mobiles. Details to follow in the next post.
How-to: Updating su and Superuser of Rooted Cherry W900 [draft 00]
Consider this a first draft - but it is still my effort though, so no copying! lol
Here we go!
BTW
STANDARD DISCLAIMERS APPLY with regard to modding, etc paraphrasing CM "Here Be Dragons ..." etc etc
Pre-requisites:
1. Rooted W900 using the builtin CWM function; >>> see this (translate if first) for detals : LINK
2. OS with adb properly installed and able to detect the W900;
3. Recent versions os the su binary, Superuser.apk and (optionally) busybox, I used chanifire's CWM zip update and zeppelins busybox version;
4. Familiarity with the adb commands and the terminal prompt in general;
Procedure:
A. Extract the su binary and Superuser app (and busybox) in a folder;
B. Start a Terminal/ Command Prompt (administrator mode in windows i think is required);
C. Attach the phone make sure it is useable with adb, enter the following in the terminal window:
D. Start an ADB shell;
Code:
<prompt>
adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
Cherry-Mobile-W900 device
E. Start an ADB shell;
Code:
adb shell
$
F. Start a root prompt;
Code:
$ su
#
F.1. Check user ID of root prompt pre-mod as reference;
Code:
# id
Note that there is 0/ root UID/ GID mentioned as expected;
G. Prepare for update, creating symlink, enter line per line in the adb shell root prompt;
Code:
# mv /data/local/tmp /data/local/tmp.bak
# ln -s /data /data/local/tmp
# reboot
H. Phone will reboot, repeat steps E-F again, then the following to add emulator mode:
Code:
# rm /data/local.prop > nul
# echo \"ro.kernel.qemu=1\" > /data/local.prop
# reboot
I. Phone will reboot into emulator mode now, repeat steps E-F again, then the following:
Code:
# id
********************************************************************
One of the IDs shown should be 0/ root
//IF ID IS 0/root THEN CONTINUE, ELSE START OVER:
Go back to CWM , then unRoot, then Root again, then restart from A
********************************************************************
J. For now exit adb shell, type exit on both adb shell prompts to return to your OS terminal;
Code:
# exit
$ exit
<prompt>
K. adb push su, Superuser.apk and busybox to phone; enter in your OS terminal prompt;
Code:
adb push su /data/local/tmp.bak/
adb push Superuser.apk /data/local/tmp.bak/
adb push busybox /data/local/tmp.bak/
L. Return to adb shell, re-do steps E-F;
M. Mount system parition as RW;
Code:
# mount -o remount rw /system
N.Copy respective files to proper locations and set correct owner/ permissions;
Code:
# cd /data/local/tmp.bak/
# rm /system/bin/su
# dd if=su of=/system/bin/su
# chown 0.0 /system/bin/su
# chmod 06755 /system/bin/su
# ls -l /system/bin/su <<< check first
# -rwsr-sr-x root root 22364 2008-02-29 02:33 su <<< this should be the result
Code:
# dd if=Superuser.apk of=/system/app/Superuser.apk
# chown 0.0 /system/app/Superuser.apk
# chmod 0644 /system/app/Superuser.apk
*********
N.1: following is optional but highly recommended - busybox installation
*********
Code:
# dd if=busybox of=/system/xbin/busybox
# chown 0.0 /system/xbin/busybox
# chmod 0755 /system/xbin/busybox
# /system/xbin/busybox --install -s /system/xbin
O. Cleanup, remove emulator mode, temp files;
Code:
# rm /data/local.prop
# rm /data/local/tmp
# mv /data/local/tmp.bak /data/local/tmp
# reboot
After that final reboot, you should now have a proper working Superuser app with prompts and everythings, and root apps like Titanium and link2sd work with no warnings.
On review, I really thought that step G. is an extraneous step, but all these were the steps I did to make it work. I did go thru a few trials before things finally stuck though so for completeness that step is still in there just in case. - I never could do step H without step G I think.
Filipino??? Ive installed sdk and its components, usb drivers. I have adb working, but when i tried to find the connected devices in cmd it shows that there is no device connected.
Ive type this code:
adb devices
List of devices attached:
and it shows nothing
Can you teach me how to configure the device or the adb?
Failed to get shell root
Mine says failed to get shell root, I also tried the superoneclick method and the sk-150 bat file thing, the latter just installs Superuser Superuser Elite and the Root Explorer but doesnt actually root it. Is there any other method out there to actually root this thing?
nah got it rooted using recovery method, now following your instructions, SUPER THANKS!!!
try this to root www.symbianize.com/showthread.php?t=811934
@ashralee
how did you root your phone?
mine wont work?
do you have to do something like
fastory reset or or have to turn on/off
something?
i just followed the steps on rootunlock
and root recovery but it both dont work
on my phone.
pls help me
thanks in advance.
http://www.facebook.com/groups/cher...group/284336801681086/?notif_t=group_activity
try this fb group maybe someone will help you how to root your phone
Help about cwm..i just backed up my stock rom b4 flashing to xperia custom rom.but when i tried to revert it back to my stock rom..cwm says md5 mismatch..what seems to be the problem?please anyone,,help me with this matter..thanks in advance..
Sent from my R800 using xda app-developers app

Backup | Protect | Restore - root (su)

For experienced users only.
As the thread title suggests, this is a guide to backup, protect and restore root (su) as is sometimes needed after a system upgrade, broken Superuser update, etc...
Yes, there is an app for this, but if your like me, and enjoy full control over your system and don't mind working from the terminal, than this guide is for you.
What's involved:
We will be using two Linux commands orignially for the Linux second extended file system (ext2) but also works on ext3 and ext4.
- chattr (change file attributes)
- lsattr (list file attributes)
What's needed:
1. Terminal Emulator - there is an excellent one by Jack Palevich HERE
2. BusyBox compiled with the aforementioned utils/applets - an excellent pre-built binary by Linus Yang can be found HERE
-- I've also created a flashable zip for Linus Yang's BusyBox HERE
3. Extended file system as previously mentioned
A picture is worth a 1000 words:
Let's start with that and then review below
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
su ~ we need root access rights to make changes to the system
mount -o remount ~ we remount the system rw (read/write) to make the changes
cp -p ~ we copy/backup the su binary preserving (-p) the current file attributes/permissions, i.e. [rwsr-sr-x root root]
lsattr ~ list attributes; shows the files immutable bit is unset (not protected)
chattr +i ~ the +i is to set the immutable bit on the file
lsattr ~ list attributes; shows the files immutable bit is now set (protected)
chattr -i ~ the -i is to unset the immutable bit on the file
lsattr ~ list attributes; again, shows the files immutable bit is unset (not protected)
mount -o remount,ro ~ we remount the system read-only when finished making changes (always - don't forget)
Now what:
To restore root (su), i.e. after a system upgrade, we call the (su)protected /system/su-bak from terminal and use it to restore root access rights to /system/bin/su
Code:
/system/su-bak
mount -o remount,rw /system
chown 0.0 /system/bin/su
chmod 06755 /system/bin/su
mount -o remount,ro /system
Notes:
-In all my examples above, my su binary is in the /system/bin folder, however yours may very well be in the /system/xbin folder, so handle accordingly
-As long as the upgrade (OTA) is an in-place file system update then this should work, it is essentially the same process as the OTA RootKeepers
Sources and info:
chattr:
http://en.wikipedia.org/wiki/Chattr
http://linuxcommand.org/man_pages/chattr1.html
lsattr:
http://en.wikipedia.org/wiki/Lsattr
http://linuxcommand.org/man_pages/lsattr1.html
-JR-

[CHROOT] Debian install on android with root

We need:
-debian chroot tarball or raspberry pi image (Download debian arm64 tarball)
-Magisk
-busybox (Magisk module avaible)
-GNU/Linux(for adb shell)
-Android terminal emulator (Download))
1- download tarball or image on computer
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2-push file to /sdcard/ directory
3-Open android shell. Move file to /data/ and unpack file
4- Move rootfs to /data/linux
5- now go phone and run mount.sh in terminal (AOSP terminal has issue so We need another terminal)
6- If phone doesn't have busybox You must use busybox magisk module or any busybox installer.
7-after that reboot phone and run mount.sh in terminal
8-run chroot.sh in terminal and check update
9- done
Notes:
-if you want to install gui, You can install vnc server and connect in android vnc viewers.
-You can only install arm64/arm architecture rootfs.
-if you access system directory in rootfs, You can create /data/linux/system/
-if apt doesnt have internet access, edit /data/linux/etc/passwd file and replace _apt users UID to 0
-If you have any questions, You tell me
Mount.sh
Code:
#!/bin/sh
busybox mount --bind /dev dev
busybox mount --bind /sys sys
busybox mount --bind /proc proc
busybox mount --bind /data/cache tmp
busybox mount --bind /dev/pts dev/pts
busybox mount --bind /system system #optional
busybox mount --bind /sdcard root
Chroot.sh
Code:
#!/bin/sh
export TERM=linux
export TMPDIR=/tmp
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export USER=root
export HOME=/root
/system/bin/chroot . /bin/bash
Is chroot support present in stock kernel?
kvsjxd said:
Is chroot support present in stock kernel?
Click to expand...
Click to collapse
Yes. Just root needed.
An alternative method to do a ubuntu/debian chroot would be to install Termux and just follow the instructions on the termux-ubuntu repository on Github.
Basically you download a script and it installs everything for you.
The readme file of the repo follows:
A script to install Ubuntu chroot in Termux
You need to install wget and proot in Termux before using this script.
Code:
pkg install wget proot
The script will make its files in the current directory. So if you want your Ubuntu-filesystem at a particular location switch to that folder first and then call the script with it's relative path. Example:
Code:
mkdir -p ~/jails/ubuntu
cd ~/jails/ubuntu
wget https://raw.githubusercontent.com/Neo-Oli/termux-ubuntu/master/ubuntu.sh
bash ubuntu.sh
After running it you can run "start-ubuntu.sh" to switch into your ubuntu
Click to expand...
Click to collapse

TWRP Flashable BootSplash ZIP and CMD/Terminal Option

Just a simple TWRP Flashable BootSplash Zip for example to replace the warnings when you unlocked/rooted your device.
It will open up_param.bin and repack it with the jpg,s inside the zip.
Simply replace svb_orange.jpg and logo.jpg with a jpg of your own choice.
Make sure the images don't exceed 500kb, and keep exact same resolution (1440x3040 24bbp)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
*** Download ***
Script:
Code:
#!/sbin/sh
OUTFD=$2
ZIP=$3
ui_print() {
echo -n -e "ui_print $1\n" > /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" > /proc/self/fd/$OUTFD
}
cd /tmp
rm -rf arter97
mkdir arter97
cd arter97
unzip -o "$ZIP"
ui_print " - mounting data partition"
mount /data
if [ ! -e /data/media/0/up_param.bak ]; then
ui_print " - backing up current up_param to /sdcard/up_param.bak"
cat /dev/block/platform/13d60000.ufs/by-name/up_param > /data/media/0/up_param.bak
chown 1023:1023 /data/media/0/up_param.bak
chmod 664 /data/media/0/up_param.bak
fi
ui_print " - installing new logo.jpg"
chmod 755 tar
mkdir tartemp
cd tartemp
/tmp/arter97/tar -xf /dev/block/platform/13d60000.ufs/by-name/up_param
cp /tmp/arter97/logo.jpg .
chown root:root *
chmod 444 logo.jpg
touch *
/tmp/arter97/tar -pcvf ../new.tar *
cd ..
cat new.tar > /dev/block/platform/13d60000.ufs/by-name/up_param
ui_print " - installing new svb_orange.jpg"
chmod 755 tar
mkdir tartemp
cd tartemp
/tmp/arter97/tar -xf /dev/block/platform/13d60000.ufs/by-name/up_param
cp /tmp/arter97/svb_orange.jpg .
chown root:root *
chmod 444 svb_orange.jpg
touch *
/tmp/arter97/tar -pcvf ../new.tar *
cd ..
cat new.tar > /dev/block/platform/13d60000.ufs/by-name/up_param
ui_print " - unmounting partition /data"
umount /data > /dev/null 2>&1
ui_print " "
ui_print "finished"
ui_print "Edited for s10+ by Whiskey103"
cd /
rm -rf /tmp/arter97
sync
Installation method with terminal command without TWRP (pushing up_param.bin using dd cmd on phone):
Download up_param.bin
https://www.whiskey103.nl/index1.php?dir=SamsungS10-Plus/BootSplash/s10plus/
Place in root of internal memory
Open terminal on phone like Material Terminal for example:
command:
su
command:
dd if=/sdcard/up_param.bin of=/dev/block/platform/13d60000.ufs/by-name/up_param
Credits:
@Radzian - used his base zip and edited for s10+
@ianmacd for pointing to the error in my first attempt.
Can you make for S10?
1jkan said:
Can you make for S10?
Click to expand...
Click to collapse
Yea, that's on my to do list.
Just have to get my hands on a s10 up_param.bin still.
The files are most likely the same, the zip will probably just work already.
Perhaps you can upload me your up_param.bin?
Where is this file?
1jkan said:
Where is this file?
Click to expand...
Click to collapse
Run the follow commands on your device in terminal.
su
cat /dev/block/platform/13d60000.ufs/by-name/up_param > /data/media/0/up_param.bak
It will pull up_param.bin and place it as up_param.bak on your internal SD card
Share it here please.
I can not handle it.
I try all the time but I can not. Maybe someone more experienced will help
1jkan said:
I try all the time but I can not. Maybe someone more experienced will help
Click to expand...
Click to collapse
Judging by the fact you are lookin to remove the boot warnings it's safe to say you're rooted.
Once rooted, go to playstore, grab a terminal app like Material Terminal.
Open it, typ su on first line. It will show #.
Then the command I gave you, it should be easy
1jkan said:
I try all the time but I can not. Maybe someone more experienced will help
Click to expand...
Click to collapse
try this:
https://www.whiskey103.nl/index1.ph...plash/&file=TWRP-Flashable_BootSplash_S10.zip
will this work for at&t s10+ snapdragon? please advise, thank you!
PTJunkie1975 said:
will this work for at&t s10+ snapdragon? please advise, thank you!
Click to expand...
Click to collapse
I cant test that obviously, at least needs root/unlocked bootloader etc.
I have Terminal Material. I have entered commands several times but there is always a failure. Not found
Whiskey103 said:
try this:
https://www.whiskey103.nl/index1.ph...plash/&file=TWRP-Flashable_BootSplash_S10.zip
Click to expand...
Click to collapse
This file works great. For full happiness is only missing, so that there is no Magisk stamp ...
Can I flash this with flashify?
daveuk87 said:
Can I flash this with flashify?
Click to expand...
Click to collapse
no, needs twrp.
Maybe i will add a different way with pre-made up_param.bin to be pushed with terminal later.
daveuk87 said:
Can I flash this with flashify?
Click to expand...
Click to collapse
Installation method with terminal command without TWRP (pushing up_param.bin using dd cmd on phone):
Download up_param.bin
Place in root of internal memory
Open terminal on phone like Material Terminal for example:
command:
su
command:
dd if=/sdcard/up_param.bin of=/dev/block/platform/13d60000.ufs/by-name/up_param
@Whiskey103 Will there be bootlog update for android 10? first of all, Thanks
Note: the "by android" logo change and the size of the samsung s10 (x) name too.
note2: I have a galaxy 10+
:fingers-crossed:

[Guide][MOD][THEME] Enable WhatsApp Desktop Dark Mode in MacOS

WhatsApp is set to receive the much-awaited dark mode on desktop platforms. According to a recent report by WABetaInfo, WhatsApp Web and WhatsApp for PC/Mac are currently being tested with a dark theme that paints the main screen and side panel in varying shades of dark grey. In recent builds the code for dark mode is available but there's no official option to enable it. So here's how can you enable it yourself.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Enable dark mode in WhatsApp Desktop version of MacOS (Although it must be similar in windows client too)
PREREQUISITES
What things you need to install before starting up WhatsApp Desktop Application Homebrew Nodejs asar node module Installing section is just to install prerequisites if you already don't have them. Otherwise skip to Applying Dark Mode.
INSTALLING
Follow these Steps:
You need to install Whatsapp Desktop on your Mac(Download from OFFICIAL WEBSITE is suggested rather than app store version).
Open Terminal and Install Homebrew
Code:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This will install Homebrew on your Mac. To check the version type the following command.
Code:
$ brew -v
Install Nodejs using Homebrew
Code:
$ brew install node
If everything installed successfully then you can type in the following command in the terminal to check the Node and NPM version.
Code:
$ node -v
$ npm -v
Install asar node module globally
Code:
$ npm install -g asar
APPLYING DARK MODE
Go into the app’s directory and create a directory for our working
Code:
$ cd /Applications/WhatsApp.app/Contents/Resources
$ mkdir temp-darkmode
Unpack the app.asar file in the above directory using asar
Code:
$ asar extract app.asar temp-darkmode
Open directory temp-darkmode and insert the code
Code:
cd temp-darkmode
open index.html and edit
Code:
nano index.html
find body
HTML:
<body class="native darwin">
replace it with code below
HTML:
<body class="native darwin dark">
save the file, hit ctrl+x type y and enter
Pack the app.asar file,Go into the app’s directory
Code:
$ cd /Applications/WhatsApp.app/Contents/Resources
to pack type
Code:
$ sudo asar pack temp-darkmode app.asar
You are done
Source: Github

Categories

Resources