According to various tutorials this should work. <code> |import sys data = sys.stdin.readlines() print "Counted", len(data), "lines."| </code>
Please use google before asking such questions. This was found with only one search for the terms 'python read stdin' Rolf Bernard Desnoues wrote: > Hi, > > I've got a problem with the use of Redmon (redirection port monitor). I > intend to develop a virtual printer so that I can modify data sent to > the printer. > Redmon send the data flow to the standard input and lauchs the Python > program which send modified data to the standard output (Windows XP and > Python 2.5 context). > I can manipulate the standard output. > > "import sys > sys.stdout.write(data)" > > it works. > But how to manipulate standard input so that I can store data in a > string or in an object file ? There's no "read" method. > > "a = sys.stdin.read()" doesn't work. > "f = open(sys.stdin)" doesn't work. > > I don't find anything in the documentation. How to do that ? > Thanks in advance. > > Bernard Desnoues > Librarian > Bibliothèque de géographie - Sorbonne -- http://mail.python.org/mailman/listinfo/python-list