Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!cmcl2!adm!xadmx!ifenn%ee.surrey.ac.uk@nss.cs.ucl.ac.uk From: ifenn%ee.surrey.ac.uk@nss.cs.ucl.ac.uk (Ian Fenn) Newsgroups: comp.unix.wizards Subject: Detecting Pipe Using Bourne Shell Message-ID: <18992@adm.BRL.MIL> Date: 6 Apr 89 15:53:08 GMT Sender: news@adm.BRL.MIL Lines: 42 Hello all. I wonder if one of you can help me. I have a Bourne shell program which maintains a database of telephone numbers. If I enter the program with no arguments: % phone I display a main menu which offers options to change entries, delete entries, etc, etc. If I enter the program with arguments: % phone Bloggs Then it searches through the database (using grep) for the arguments in the database of telephone numbers (in this example it would look for Bloggs). I test for arguments by using: if test $# -ne then .....search for arguments in database..... .....then exit fi ....rest of program (i.e. Main Menu). The only problem with this is that I cannot pipe the output from another program into it because it drops into the main menu and out again! Probably due to the test for arguments. Can anyone therefore tell me how to detect a pipe using Sh, so that the following will work? Or suggest another way round the problem? % cat datafile | phone Thanks in advance. -- Ian Fenn, +------------------------------------------------+ Computer System Technician, | Network Address : ifenn@ee.surrey.ac.uk | | Telephone : +44 483 571281 ext. 9104 | Department of | Direct line : +44 483 509104 | Electrical Engineering, | Telex : +44 859331 | University Of Surrey, | Fax : +44 483 34139 | Guildford, +------------------------------------------------+ Surrey. | "It is easier to change the specification to | GU2 5XH. | fit the program than vice versa." | +------------------------------------------------+