better use of os.system()
cmkl
cmkleffner at gmx.de
Mon Sep 15 02:44:56 EDT 2003
Fooman <fee at fee.com> wrote in message news:<181d118be52ffabbbeaa120340c3f759 at news.teranews.com>...
> > lower: not found
> >
> > I want it to run "lower" just like it would if I typed "lower" at the
> > bash prompt. How can I do that?
>
> The problem is that the 'lower' script is not in the path that
> the python interpreter knows about. You can do:
>
> os.system("/my/nonstandard/pathto/lower")
>
> or, if you are using Linux, or similar, you can try
> making sure that your $PATH variable is getting set to
> include the path to your script in the environment that
> the python interpreter gets launched in.
>
> So, what platform are you running under, and what is the
> path to your 'lower' script, and what are the contents
> of your $PATH variable?
>
> Tobiah
You can use the standard windows Python distribution with
a little trick. First of all make sure you can start 'lower'
from a dos console.
To do that, you need a little helper cygwin shell script:
- start cygwin
- cd /bin
- create a cmd2bash script with the following content:
#! /bin/bash
$*
- chmod +x cmd2bash (make it executable)
Then start a console and try out following command:
C:\>c:\cygwin\bin\bash c:\cygwin\bin\cmd2bash "ls -la"
Do you see the content of drive C:\ in posix style?
You may need to adjust the path to cygwin.
If you have name with spaces (barf) you may need single quotes:
C:\Programme>c:\cygwin\bin\bash c:\cygwin\bin\cmd2bash "ls 'Outlook Express'"
Then try to start your lower script with:
os.system('''c:\cygwin\bin\bash c:\cygwin\bin\cmd2bash "lower"''')
btw: this trick works for msys too
Regards
Carl
More information about the Python-list
mailing list