running non-python progs from python

Spiffy spiffy at worldnet.att.net
Tue Dec 9 03:38:18 EST 2003


"Michel Claveau/Hamster" <No.Spam.mc at No.Spam.mclaveau.No.Spam.com> wrote in
message news:br3t6s$44i$1 at news-reader2.wanadoo.fr...
> Hi !
>
> You can also do (sample) :
>
>         import os
>         vret = os.popen('c:\\pfiles\\lplayer.exe')
>         print vret
>
>
>
> @+
> --
> Michel Claveau

Hello Michel, thanks for taking the time to respond. Unfortunately, when I
tried to run your sample code (changing the name of the file, of course), it
did nothing.






> How can I run this other program from a python script and pass the
filename
> as a parameter?

    import os

    filename = "myfile"
    os.system("program %s" % filename)

</F>

Fredrik, the example you provided is virtually the same as the one from the
"Learning Python" book. When I run it, the dos command line appears with the
message 'Bad command or file name". Both the .exe and the .mid file are in
the python path and the spelling has been checked.
What I expected to happen was that the os.system call would start the .exe
and begin playing the .mid file. This does not happen. This is what I meant
when I said I haven't been able to get this to work.

>"it doesn't work" is a really lousy way to describe a >problem  what did
you
>do, what happened, and what did you expect would >happen instead?
>
>also see:
>
>    http://www.catb.org/~esr/faqs/smartquestions.html#intro
>

Pardon me for being a newbie, but if you don't have an answer, why do you
have to give me attitude?







More information about the Python-list mailing list