Re: Run batch files in Windows XP

2005-07-25 Thread Benji York
Ernesto wrote:
> Looks like I'm not getting my parameters to my batch file correctly.
> I'm using os.system like this:
> os.system('bootmanager.bat %s' %"BOOTMANAGER ALL")
> 
> where 'BOOTMANAGER ALL' is what I type at the command prompt arguments.
>  That must not be right?

The batch file will see two parameters (in %1 and %2) if that's not what 
you want, put double quotes around the %s, like so:

os.system('bootmanager.bat "%s"' % "BOOTMANAGER ALL")
--
Benji York

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Run batch files in Windows XP

2005-07-25 Thread Ernesto
Looks like I'm not getting my parameters to my batch file correctly.
I'm using os.system like this:
os.system('bootmanager.bat %s' %"BOOTMANAGER ALL")

where 'BOOTMANAGER ALL' is what I type at the command prompt arguments.
 That must not be right?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Run batch files in Windows XP

2005-07-25 Thread Ernesto
Thanks.

Yeah I started to write in Python.  Looks like this:

**
import os
from os.path import join

# Get input from user and make sure it is valid

fileDirec = raw_input("\nEnter the path of where your
STMP3XXX_SDK_FIRMWARE\nis located (i.e. C:\) : ")
if not os.path.exists(fileDirec):
exit(" ** File or path does not exist... exiting ** ")


# Builds all binaries simultaneously for SDK 3.050
def buildBinaries(_path):
_bootmanagerPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\DeviceDriver\Media\SmartMedia\BootManager\STMP3500\make")
_usbmscPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\Projects\Sdk\lcdexample\usbmsc\make")
_playerPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\Projects\Sdk\lcdexample\player\make")
_mtpPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\Projects\Sdk\lcdexample\mtp\make")

# First build bootmanager...change to that directory
# and run the bootmanager file...  Similarly for the others...
os.chdir(_bootmanagerPath)
os.execl(("bootmanager.bat"),("BOOTMANAGER ALL"))

os.chdir(_usbmscPath)
os.execl(("usbmsc.bat"),("USBMSC ALL UPDATER"))

os.chdir(_playerPath)
os.execl(("player.bat"),("PLAYER ALL"))

os.chdir(_mtpPath)
os.execl(("mtp.bat"),("MTP ALL"))

 # After gathering user input, call routine to build binaries...
buildBinaries(fileDirec)
**

The issue is after the first execution of os.execl, the script stops
altogether.  In other words after bootmanager.bat executes, its over.
I would love to Python if I could get all scripts to execute (executing
simultaneously would be a major + !)
I'll try os.system
THANKS!!!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Run batch files in Windows XP

2005-07-25 Thread Peter Hansen
Ernesto wrote:
> The issue is I haven't done very much batch programming.  I need to
> prompt the user for input and each batch file is in a different
> directory.  How do I change directories and prompt for user input?

Ah, now you're talking things where Python, while not strictly required, 
can start to make things easier. :-)

To run external things like batch files, you import the "os" module and 
use the system() function:

import os
os.system('somebatchfile.bat')

Since you're prompting the user for input first, presumably the input is 
passed to the batch file in some way, like so:

input = raw_input('Enter your incredibly useful info now:')

("raw_input" is a builtin... good to learn about as many of those as you 
can handle by reading the docs here: 
http://docs.python.org/lib/built-in-funcs.html .  Some of those are 
absolutely not important to you at this early stage, others are.)

Then with the input you've collected, you could pass it to the batch 
file like so:

os.system('myfile.bat %s' % input)

The %s and % together result in whatever text the user entered being 
added on the command line for the call to myfile.bat, exactly as though 
it had been executed manually with the same input.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Run batch files in Windows XP

2005-07-25 Thread Ernesto
Thanks Peter.
The issue is I haven't done very much batch programming.  I need to
prompt the user for input and each batch file is in a different
directory.  How do I change directories and prompt for user input?
Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Run batch files in Windows XP

2005-07-25 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
> I'm a newbie and I was wondering if anyone knew a (Python) script to
> run 4 batch files, one after the other (assuming the directories are
> known).  It would be better if all 4 batch files could run
> simultaneously, but that might break Windows...  ;)  The problem I had
> was I couldn't get the files to RUN, only to OPEN.  Thanks for the
> help!!!

You shouldn't need a Python program for that.

To run the not simultaneously:

call batch1.bat
call batch2.bat
call batch3.bat
call batch4.bat

Put those commands with appropriate names in a fifth batch file and 
execute that and it will work.

To run them simultaneously (which won't break Windows, but might not do 
what you would like, depending on what those batch files actually do), 
just add the "start" command into the equation.  You can get help on the 
start command using "start /?" at a DOS prompt.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Run batch files in Windows XP

2005-07-25 Thread erniedude
Hi,

I'm a newbie and I was wondering if anyone knew a (Python) script to
run 4 batch files, one after the other (assuming the directories are
known).  It would be better if all 4 batch files could run
simultaneously, but that might break Windows...  ;)  The problem I had
was I couldn't get the files to RUN, only to OPEN.  Thanks for the
help!!!

pseudo-code looks like this

> Get directory

> Run batch1
> Run batch2
> Run batch3
> Run batch4

-- 
http://mail.python.org/mailman/listinfo/python-list