Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!munnari!murtoa.cs.mu.oz.au!mimir!hugin!augean!sirius!eco!nt!levels!ccdn From: ccdn@levels.sait.edu.au (DAVID NEWALL) Newsgroups: comp.unix.wizards Subject: Re: Detecting Pipe Using Bourne Shell Message-ID: <2412@levels.sait.edu.au> Date: 10 Apr 89 18:29:09 GMT References: <18992@adm.BRL.MIL> Organization: Sth Australian Inst of Technology Lines: 19 In article <18992@adm.BRL.MIL>, ifenn%ee.surrey.ac.uk@nss.cs.ucl.ac.uk (Ian Fenn) writes: > [ how can you tell if a program's input comes from a pipe? ] I recommend testing to see if stdin is a terminal. I believe the following will do what you want: if [ -t 0 -a $# -eq 0 ]; then echo menu ... else ... fi (I assume you only want a menu when the program is run from a terminal) David Newall Phone: +61 8 343 3160 Unix Systems Programmer Fax: +61 8 349 6939 Academic Computing Service E-mail: ccdn@levels.sait.oz.au SA Institute of Technology Post: The Levels, South Australia, 5095