Executing a system command

George Demmy gdemmy at layton-graphics.com
Thu May 23 08:21:56 EDT 2002


jb <jblazi at hotmail.com> writes:

> Chris Liechti wrote:
> 
> > jb <jblazi at hotmail.com> wrote in news:3cec0fa1_1 at news2.newsgroups.com:
> > 
> >> I should like to execute the bash command
> >> 
> >> (cd prefix;latex file.tex;dvips file)
> >> 
> >> Can I do that with the os.system function?
> > 
> > i think you can.
> > 
> >>It seems I am having diffculties with that.
> > 
> > then descibe that problem so that we can help :-)
> 
> I create the Latex source and when I want to compile it the Latex 
> compilation stops and an asteriks appears on the screen:
> 
> xxx
> xxxxxx
> *
> 
> But the latex file seems to be in order and when I do the same procedure 
> from bash, everything is in order.
> When I execute the same command from Python, that is I have
> os.system('(cd ...)')
> the compilation stops.
> 

It "can" work... I just executed a os.system command similar to yours:

os.system('cd tmp ; latex command.tex ; dvips -o foo.ps command.dvi')

and it worked fine. Do you have TeX-specific environment variables
that may not be getting  passed to the environment in which your
system command is executed? You can examine this environment by
looking at os.environ. This is a dictionary keyed by the name of the
environment variable. You can set values for the os.system environment
simply by assignment, e.g.

>>> import os
>>> os.environ['TEXHOME'] = '/foo'
>>> os.system("echo $TEXHOME")
/foo
0
>>> 

Viel glueck!

G

-- 
George Demmy
Layton Graphics, Inc




More information about the Python-list mailing list