lpr via subprocess in 2.4

Peter Otten __peter__ at web.de
Wed Aug 4 07:08:39 EDT 2010


loial wrote:

> I am am trying to run the following command via subprocess
> 
> lpr -P printqueue filetoprint
> 
> I cannot seem to get it to work and return stderr
> 
> I think the issue is how to specify the arguments
> 
> I am trying
> 
> subprocess.Popen(['lpr -P' ,'laserlpr','/etc/hosts'], shell=False)

This looks for an executable called "lpr -P"; try

subprocess.Popen(['lpr', '-P' ,'laserlpr','/etc/hosts'], shell=False)
 
> but get error :
> 
> Traceback (most recent call last):
>   File "testopen.py", line 6, in ?
>     subprocess.Popen(['lpr -P' ,'laserlpr','/etc/hosts'], shell=False)
>   File "/usr/python2.4/lib/python2.4/subprocess.py", line 558, in __in
> it__
>     errread, errwrite)
>   File "/usr/python2.4/lib/python2.4/subprocess.py", line 991, in _exe
> cute_child
>     raise child_exception
> OSError: [Errno 2] No such file or directory




More information about the Python-list mailing list