Check if stdin has data in busybox script ash or bash

226 Views Asked by At

Hi i am trying to create an ash script to read lines from stdin in a non blocking way.

In bash i can do something like this: read -t 0 && read line

But in ash on OpenWRT(LEDE version 17.01.16) i am unable to do this since on this version of OpenWRT read -t 0 is blocking :(

So how can i check if stdin has some data to read.

In particular i want to read a line from stdin if input is available otherwise just skip and will try later.

Is there any other possibile way to do this?

0

There are 0 best solutions below