Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!thyme!kaleb From: kaleb@thyme.jpl.nasa.gov (Kaleb Keithley ) Newsgroups: comp.unix.programmer Subject: Re: named pipes and .plan Message-ID: <1990Sep27.231228.20616@thyme.jpl.nasa.gov> Date: 27 Sep 90 23:12:28 GMT References: <5932@ge-dab.GE.COM> Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 58 In article coleman@sunny.DAB.GE.COM (Richard Coleman) writes: >-- >Could someone send me or post a simple example >of sending program output to .plan when someone uses >the finger command. It would be greatly appreciated. > Here's the one I wrote as a result of this thread. It does work, feel free to finger me (kaleb@nutmeg.jpl.nasa.gov) if you doubt my word. It may not be the epitome of efficiency, so I'll gladly take tips on making it better. #include #include #include #include main () { int planfile; int number = 0; time_t tim; char *planmessage = "You are the %d%s person to finger me\nat the tone, the time will be %s\n"; char target[256]; char *consmessage = "you have been fingered\n"; char *index2; for (;;) { planfile = open (".plan", O_WRONLY ); time (&tim); switch (number % 10) { case 1: index2 = "st"; break; case 2: index2 = "nd"; break; case 3: index2 = "rd"; break; default: index2 = "th"; break; } sprintf (target,planmessage, number++, index2, asctime (localtime (&tim))); write (planfile, target, strlen (target)); write (1, consmessage, strlen (consmessage)); close (planfile); sleep (1); } } -- Kaleb Keithley Jet Propulsion Labs kaleb@thyme.jpl.nasa.gov Stirring up trouble again.