set interactive [ expr ! [ catch { exec /bin/sh -c { [ -t 0 ] }}]]
RFox - 2013-05-29 11:13:27What about checking the value of tcl_interactive?
jrw32982 tcl_interactive doesn't tell you if you're running interactively (if your script can receive input from a terminal). It tells you if you're running a script.
PYK 2015-03-12: AMG and others have suggested variations on
catch {fconfigure stdout -mode}or
catch {fconfigure stdout -xchar}