Thursday, December 11, 2008

Python os.spawnl returns error code 127

In this blog I am giving solution to the most common problem when programmers try to execute os.spawnl command. Most of the programmers get 127 error code at the time of executing command os.spawnl. For example

>>> import os
>>> os.spawnl(os.P_WAIT, 'ls', 'ls', '-l')
127

The error code "127" means that the system can't find the exectuable.

Solution: Use absolute pate of the executable.

>>> import os
>>> os.spawnl(os.P_WAIT, '/bin/ls', 'ls', '-l')
-r-xr-x--- 1 abc unknown 2994 Nov 5 21:25 create_
-rw------- 1 xyz unknown 7938048 Oct 8 19:09 nohup.out
0

Hope, this trick helps you.

No comments: