[Tutor] write to /dev/stdin during call to posix command?
Kent Johnson
kent_johnson at skillsoft.com
Fri Sep 17 01:45:09 CEST 2004
Did you try
pdfinput = open('sample.pdf','r').read()
r,w,e = os.popen3('pdftotext -layout /dev/stdin -')
r.write(pdfinput)
?
Kent
At 01:16 PM 9/10/2004 -0400, Jeff Kowalczyk wrote:
>How can I write to /dev/stdin during a call to a posix command? The
>pdftotext command will write to stdout if given '-' as the output
>filename, but it lacks the same paramater for reading from stdin.
>
>However, using /dev/stdin and directing a file to the input works fine:
>
># pdftotext -layout /dev/stdin - < sample.pdf
>
>Reading from stdout with a physical file input is no problem:
>
>r,w,e = os.popen3('pdftotext -layout sample.pdf -')
>w.read() # gives the text string I am looking for
>
>But I don't quite understand how I should send a string representing the
>input pdf (pdfinput) to the version of the command using /dev/stdin:
>
>pdfinput = open('sample.pdf','r').read()
>r,w,e = os.popen3('pdftotext -layout /dev/stdin -')
>
>Any ideas? I'm using python-2.3.4, linux. Thanks.
>
>Jeff
>
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list