How to run commands in command line from a script
Ivan Shevanski
darkpaladin79 at hotmail.com
Thu Jun 30 23:43:00 EDT 2005
Alright well I'm quite a noob and when I run a simple command to change the
current directory, nothing happens. I made a little test script to show it:
import os
cwd = os.getcwd()
print cwd
os.system('cd = C:\Program Files')
print cwd
then the result:
C:\Python24\Python Scripts
C:\Python24\Python Scripts
The cd never changed. . . Can somebody explain this? I think I need to add
something simple, i didnt quite get the example ' os.system('./some
--command') '
-Ivan
>From: Robert Kern <rkern at ucsd.edu>
>To: python-list at python.org
>Subject: Re: How to run commands in command line from a script
>Date: Thu, 30 Jun 2005 20:01:29 -0700
>
>Ivan Shevanski wrote:
> > I know there is an easy way to do this, and I just can not remember. I
>have
> > already searched where I thought the module would be. . . I just want to
>run
> > some name specific commands. Is this easily possible?
>
>Quick and dirty:
>
> import os
> os.system('./some --command')
>
>More robust: Use the subprocess module.
>
>--
>Robert Kern
>rkern at ucsd.edu
>
>"In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."
> -- Richard Harter
>
--
_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
More information about the Python-list
mailing list