Access stdout from external program.

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Aug 2 10:50:03 CEST 2010


Paul Lemelle wrote:
> Hi JM,
>
> My last dumb question:  When I try to run the below script as an 
> executable, I get the following error:
> pttdev at pttTestVM:~$ ./argv.py 4
> import: unable to open X server `/tmp/launch-c8feFG/org.x:0' @ 
> import.c/ImportImageCommand/361.
> ./argv.py: line 8: syntax error near unexpected token `print'
> ./argv.py: line 8: `       print x'
>
> The script:
> # Writing the output to a standard argv argument
>
> #!/usr/bin/env python
>
> import sys
>
> for x in sys.argv:
>        print x
>  
>
> #END
>
> Any idea why?
>
> Thanks,
> Paul
>

Please don't remove python-list.

I see 2 possibilities:

1/ this is related to the open X server, for that I can't help you, 
something related to your exported display if you're remotely logged on 
the machine
2/ you are using python 2.x syntax within a python 3 interpreter. Try 
"print (x)".


JM



More information about the Python-list mailing list