472,328 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

better use of os.system()

How can I make it so that I can pass anything into os.system() any
command that I would type into the command line (bash on cygwin)? For
example, "lower" is a small script of mine that I use frequently, and
I would like to be able to call if from python. os.system("lower")
results in:
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?
Jul 18 '05 #1
4 45770
Bob Roberts wrote:
How can I make it so that I can pass anything into os.system() any
command that I would type into the command line (bash on cygwin)? For
example, "lower" is a small script of mine that I use frequently, and
I would like to be able to call if from python. os.system("lower")
results in:
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?


If you're using the standard windows Python distribution, try setting
%CMDSPEC% to the path of your bash.exe.

If you're using the cygwin python, then I don't know if CMDSPEC or SHELL
is the right one.

Daniel

Jul 18 '05 #2
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

Jul 18 '05 #3
Fooman <fe*@fee.com> wrote in message news:<18******************************@news.terane ws.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
Jul 18 '05 #4
Fooman <fe*@fee.com> wrote in message news:<18******************************@news.terane ws.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?

I am running under cygwin (it acts like linux in many respects), using
the cygwin-built version of python. The path to "lower" is
~/bin/lower, and ~/bin is in my $PATH.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's...
3
by: Muhd | last post by:
<usualDisclaimer>Please forgive me if this is in the wrong group, and if so, what is the right group.</usualDisclaimer> Let me start off by first...
15
by: ham-z | last post by:
I have written the following Win app in VB.NET 2003 . The class is simply picture boxes that behave in a random order after they have been...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
22
by: David Sterling | last post by:
After much futzing about with the XML/XSD for the Search.Response, I had to resort to this... PLEASE Tell me there is a better way! private...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert...
1
by: Chad A. Beckner | last post by:
Hey all, I am developing a workshop registration system, and am new to ASP .NET. On my first page, I want to list the "categories" available...
3
by: Paul | last post by:
With respect to performance, is either of these better? Dim myTextBox As New TextBox or Dim myTextBox As TextBox myTextBox = New TextBox ...
43
by: Rob R. Ainscough | last post by:
I realize I'm learning web development and there is a STEEP learning curve, but so far I've had to learn: HTML XML JavaScript ASP.NET using...
1
by: unwantedspam | last post by:
I am new to asp.net. Is there a better way to do the following code? Dim Cell1 As New System.Web.UI.WebControls.TableCell Dim Cell2 As New...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.