Thanks @user3258569
, script is maybe the only thing that works in busybox
!
The shell was freezing for me after it, though. Looking for the cause, I found these big red warnings "don't use in a non-interactive shells" in script manual page:
script
is primarily designed for interactive terminal sessions. When stdin is not a terminal (for example:echo foo | script
), then the session can hang, because the interactive shell within the script session misses EOF andscript
has no clue when to close the session. See the NOTES section for more information.
True. script -c "make_hay" -f /dev/null | grep "needle"
was freezing the shell for me.
Countrary to the warning, I thought that echo "make_hay" | script
WILL pass a EOF, so I tried
echo "make_hay; exit" | script -f /dev/null | grep 'needle'
and it worked!
Note the warnings in the man page. This may not work for you.