Running "source" from python

Posted by R S on Stack Overflow See other posts from Stack Overflow or by R S
Published on 2010-06-17T16:36:22Z Indexed on 2010/06/17 16:43 UTC
Read the original article Hit count: 240

Filed under:
|
|

Hello,

I have a file a.txt with lines of commands I want to run, say:

echo 1
echo 2
echo 3

If I was on csh (unix), I would have done source a.txt and it would run. From python I want to run os.execl with it, however I get:

>>> os.execl("source", "a.txt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/os.py", line 322, in execl
    execv(file, args)
OSError: [Errno 2] No such file or directory

How to do it?

© Stack Overflow or respective owner

Related posts about python

Related posts about csh