Skip to content

Instantly share code, notes, and snippets.

@RWJMurphy
Created February 4, 2013 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RWJMurphy/4704592 to your computer and use it in GitHub Desktop.
Save RWJMurphy/4704592 to your computer and use it in GitHub Desktop.
Reads lines from stdin, appends a timestamp and prints to stdout
#!/usr/bin/env python
from __future__ import print_function
from datetime import datetime
import sys
def main():
try:
while 1:
line = sys.stdin.readline()
if line == '':
break
print("{}\t{}".format(datetime.now().isoformat(), line), end="")
sys.stdout.flush()
except KeyboardInterrupt:
pass
return 0
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment