Following test option may be used to check whether the stdin in a given script is a terminal
[ -t 0 ]
[ -t 1 ]
[ -T 0 ]
[ -T 1 ]