SNQ: stdin with both a pipe and keyboard

Pedro Rodriguez pedro_rodriguez at club-internet.fr
Wed Jan 22 08:53:00 CET 2003


On Tue, 21 Jan 2003 22:43:33 +0100, Dennis Lee Bieber wrote:

> Michael Ressler fed this fish to the penguins on Tuesday 21 January 2003
> 11:35 am:
> 
> 
>> 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.
>>
>         So far as I know, raw_input() reads via sys.stdin -- which means
>         it is
> trying to read your pipe which, after the data was already read in is at
> EOF.
> 
>         I don't know enough to state if you can close and reopen
>         sys.stdin to
> redirect it back to the console.
> 
>         Might be easier to design it to read the destination file name
>         as a
> command line argument and not prompt for it.
> 
>         cat datafile | transfer_file /destinationfilename/
 
You may also try passing it :

    ( echo /destinationfilename/ ; cat datafile ) | transfer_file

Pedro




More information about the Python-list mailing list