How to make an os.system call, without the pop up of the dos-box???

Stuart Ford stuart at forddata.com
Fri Aug 4 14:28:44 EDT 2000


Peter,

Use the os.spawnv(mode, path, args) function.

The spawnv mode parameter sets the execution mode of the called process,
here are the two most common modes:

os.P_WAIT - waits for the called process to complete before resuming
execution of your script.

os.P_DETACH - calls the new process and continues to run your script.

The path parameter is the path to the called process.

The args paramter contains a list or tuple containing the command line
arguments for the called process.


Example:

os.spawnv(os.P_WAIT, 'rmdir', (' ', '/S', '/Q', r'C:\arwa\dev\'))

There is a bug in the 1.5.2 spawnv call!! You need to add a space to
the first argument, or the command line args will not be processed
properly.  I get around this by passing a single space as the first
argument.

I use this workaround method in the above example.


Stuart Ford

---- Original Message -----
From: "Peter Arwanitis" <arwanitis at iabg.de>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Friday, August 04, 2000 11:59 AM
Subject: How to make an os.system call, without the pop up of the dos-box???


> Hi there,
>
> I try to call some system-calls under a windows-environment, but I'm not
> able to make this in "invisible" mode...
>
> there are calls like:
> os.system(r'rmdir /S /Q C:\arwa\dev\') #clear dir-structure recursive
>
> or
>
> os.system(r'copy ..\AccessDB_ORIG\OrigPTC.mdb
> ..\AccessDB_ORIG\PTC-000526.mdb')
>
> stuff like that :)
>
> any hints?
>
> thanks a lot
> (=PA=)
>
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list