SNQ: stdin with both a pipe and keyboard

Michael Ressler ressler at cheetah.jpl.nasa.gov
Tue Jan 21 14:35:25 EST 2003


Stupid newbie question: I'm trying to cobble together a little routine
that will accept a bunch of data presented to it on stdin, then ask for
a filename to save it to. Something like

cat datafile | transfer_file

where "transfer_file" asks "What destination?" and expects me to type in.

I've been using sys.stdin.read() to suck in the data, but if I then use
raw_input() or something like it to ask for the filename, I get an EOF
error; like raw_input() was already expecting the keyboard text to
be there without waiting for it.

Any pointers? Thanks.

Mike






More information about the Python-list mailing list