Addtime
// gcc addtime.c -o addtime
// By fnikala¤gmail.com modified and secured by
jonelf¤gmail.com
//
// Say you have a program that gives you some kind
// of status message that you want to keep in a log file
// but the said program does not give you a time stamp.
// Usage example: checkip | addtime >>logfile.log
// Resulting row in logfile.log:
// 07-05-10 12:37 The status from the checkip program
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
time_t tmytime;
struct tm* smytime;
char inp[1984];
while(fgets(inp,1984,stdin)) {
time(&tmytime);
smytime=localtime(&tmytime);
printf("%02d-%02d-%02d %02d:%02d:%02d %s\n", smytime->tm_year%100,
smytime->tm_mon+1, smytime->tm_mday,
smytime->tm_hour, smytime->tm_min, smytime->tm_sec, inp);
}
return EXIT_SUCCESS;
}