Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!tikal!dave From: dave@tikal.Teltone.COM (news) Newsgroups: comp.unix.questions Subject: Re: correct isatty usage Message-ID: <1161@tikal.Teltone.COM> Date: 23 Feb 89 16:03:24 GMT References: <18432@adm.BRL.MIL> Reply-To: dave@tikal.UUCP (David Karr) Organization: Teltone Corp., Kirkland, WA Lines: 30 In article <18432@adm.BRL.MIL> Pabbisetty.henr@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@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."