Article View: comp.unix.programmer
Article #919Re: named pipes and .plan
From: Kaleb Keithley
Date: Thu, 27 Sep 1990 23:12
Date: Thu, 27 Sep 1990 23:12
58 lines
1942 bytes
1942 bytes
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 <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <fcntl.h>
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.
Technical Details
Message-ID:
<1990Sep27.231228.20616@thyme.jpl.nasa.gov>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!thyme!kalebReferences:
<5932@ge-dab.GE.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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