correct isatty usage
news
dave at tikal.Teltone.COM
Fri Feb 24 02:03:24 AEST 1989
In article <18432 at adm.BRL.MIL> Pabbisetty.henr at xerox.com (Nagesh Pabbisetty) writes:
>> I am trying to use this invokation:
>>
>> if (isatty (stdin))
>
>
>Use the following segment of code:
>
> if (isatty(fileno(stdin))) {
> printf("Hello> ");
> fflush(stdout);
> }
Now my question is, how would you do this in a script? Either C or Bourne.
In C shell, I have this code, but it doesn't appear to work.
if ({`test -t 0`}) then
echo -n "==> "
else
echo -n "--> "
endif
It should print "-->" if stdin isn't coming from a terminal, but it doesn't
seem to work that way. It always prints "==>".
--
----------------------------------------
David Karr dave at tikal.Teltone.COM or ...uw-beaver!tikal!dave
Teltone Corp., 10801 120th Ave. NE, Kirkland, WA 98033 (206)827-9626
"The above statements do not necessarily reflect the opinions of my employer."
More information about the Comp.unix.questions
mailing list