By kramer

2019-03-09 08:22:55 8 Comments

I'm trying to display message on TWRP 3.2.3-0 recovery screen using a .sh file. i was thinking using echo command to make that.

my update-script is like this

ifelse(is_mounted("/system"), unmount("/system"));
ifelse(is_mounted("/data"), unmount("/data"));
ui_print("-- Mount partitions...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0755, "/tmp/");
ui_print("END OF PROCESS");

and my sh file is


if [ ! -e "/efs/imei/mps_code.dat" ]; then
    mount /efs
csc_id=`cat /efs/imei/mps_code.dat`
echo "$csc_id" > /tmp/csc_id.prop   
echo "Your active csc is $csc_id"

echo works because i see it in recovery log but displays nothing on recovery screen

Is there a way to activate echo or an other command to display message on recovery screen using sh file?


@iBug 2019-03-09 11:33:53

This piece of code is extracted from the ZIP package of SuperSU. It's working correctly on all devices I've ever had (displaying text to the TWRP terminal)

readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
if [ "$?" -eq "0" ]; then
  # rerouted to log file, we don't want our ui_print commands going there

  # we are probably running in embedded mode, see if we can find the right fd
  # we know the fd is a pipe and that the parent updater may have been started as
  # 'update-binary 3 fd zipfile'
  for FD in `ls /proc/$$/fd`; do
    readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
    if [ "$?" -eq "0" ]; then
      ps | grep " 3 $FD " | grep -v grep >/dev/null
      if [ "$?" -eq "0" ]; then

ui_print_always() {
  echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
  echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD

To display message, use ui_print_always "some message" instead of echo.

@kramer 2019-03-09 12:14:42

thanks for your answer but it doesn't work for me. recovery log is /tmp/ line 32: can't create /proc/self/fd/: Is a directory. do you use this code in sh file and sheban is #!/sbin/sh ?

@iBug 2019-03-09 12:41:38

@kramer You need to set OUTFD=1 beforehand.

@kramer 2019-03-09 13:11:12

Thanks a lot ... now it works

Related Questions

Sponsored Content

1 Answered Questions

0 Answered Questions

Missing internal SD card in /dev/block, phone won't start

1 Answered Questions

0 Answered Questions

TWRP - Redirect script stdout to recovery output

0 Answered Questions

TWRP: compress files using file manager

  • 2017-06-28 14:47:50
  • wiki
  • 219 View
  • 0 Score
  • 0 Answer
  • Tags:   twrp

0 Answered Questions

Make TWRP recovery permanent

1 Answered Questions

1 Answered Questions

TWRP Recovery stuck at splash screen

2 Answered Questions

[SOLVED] Nexus 6 failed to update OTA 6.0.1 from MMB29V to MMB20X

0 Answered Questions

A few Questions about Recovery

Sponsored Content