Executing external programs with vars

Fredrik Lundh effbot at telia.com
Fri Feb 4 04:57:42 EST 2000


Mike Partin <wking at sheltonbbs.com> wrote:
> Hi, I'm relativly new to python as a language, I started trying to pick it
up
> to implement a shell script I have done for helping with CVS use. I'm not
> having problems executing external programs per say, it's that I'm having
> problems executing them and including variables. For example, when
updating a
> cvs module I set my variable TempVar with raw_input() then when I exec cvs
I
> need it to be in the form "cvs -z3 co TempVar" but can't seem to get this
to
> work. Any help would be appreciated.

I assume you mean that you want the command to
include the current *contents* of TempVar, right?

    Command = "cvs -z3 co " + TempVar
    os.system(Command)

alternatives include the %-formatting operator,
or using join to build the command from bits and
pieces.

reading the "output formatting" chapter in the
tutorial might help, too.

</F>





More information about the Python-list mailing list