Re: [Tutor] running a .exe

2005-12-22 Thread Robin Buyer
Ahh. That helps a lot. Thanks.
-Robin
- Original Message -
From: "Kent Johnson" <[EMAIL PROTECTED]>
To: "Python Tutor" 
Sent: Thursday, December 22, 2005 7:46 PM
Subject: Re: [Tutor] running a .exe


> Robin Buyer wrote:
> > I created a small program to test os.system:
> >
> > import os.path
> > os.system("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
> >
> > when i run this from the command line I get an error message:
> > 'C:\Program' is not recognized as an internal or external command,
operable
> > program or batch file.
> >
> > How do you put spaces into a path name?
>
> The same way you do if you are typing the command directly to the shell -
put it in
> quotes. So now there are two sets of quotes - one to tell Python it is a
string, and one
> to pass to the shell:
> os.system('"C:\Program Files\Internet Explorer\IEXPLORE.EXE"')
>
> Alternately use subprocess.call() which takes a list of command-line
parameters so it
> knows to quote the first arg:
>   >>> import subprocess
>   >>> subprocess.call([r'C:\Program Files\Internet
Explorer\IEXPLORE.EXE'])
>
> Also note that if you want to use paths with \ in them in Python strings
you should use a
> raw string, otherwise the \ start escape sequences that you don't intend:
> os.system(r'"C:\Program Files\Internet Explorer\IEXPLORE.EXE"')
>
> Kent
>
> PS please respond to the list.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] running a .exe

2005-12-22 Thread Kent Johnson
Robin Buyer wrote:
> I created a small program to test os.system:
> 
> import os.path
> os.system("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
> 
> when i run this from the command line I get an error message:
> 'C:\Program' is not recognized as an internal or external command, operable
> program or batch file.
> 
> How do you put spaces into a path name?

The same way you do if you are typing the command directly to the shell - put 
it in 
quotes. So now there are two sets of quotes - one to tell Python it is a 
string, and one 
to pass to the shell:
os.system('"C:\Program Files\Internet Explorer\IEXPLORE.EXE"')

Alternately use subprocess.call() which takes a list of command-line parameters 
so it 
knows to quote the first arg:
  >>> import subprocess
  >>> subprocess.call([r'C:\Program Files\Internet Explorer\IEXPLORE.EXE'])

Also note that if you want to use paths with \ in them in Python strings you 
should use a 
raw string, otherwise the \ start escape sequences that you don't intend:
os.system(r'"C:\Program Files\Internet Explorer\IEXPLORE.EXE"')

Kent

PS please respond to the list.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] running a .exe

2005-12-22 Thread Robin Buyer
The internet was just an example. I'm just looking at how to open .exe from
python.
- Original Message -
From: "Liam Clarke-Hutchinson" <[EMAIL PROTECTED]>
To: "'Robin Buyer'" <[EMAIL PROTECTED]>; 
Sent: Thursday, December 22, 2005 7:35 PM
Subject: RE: [Tutor] running a .exe


> Hi Robin,
>
> Normally you would use
>
> import os
>
> os.system("c:/windows/iexplore.exe") # Or wherever it lives
>
> Build as you're attempting to run internet explorer you could use  -
>
> import webbrowser
>
> webbrowser.open("http://www.google.co.nz";) #Assuming IE is system default
> broswe
>
>
> Liam Clarke-Hutchinson| Contact Centre Advisor| Ministry of Economic
> Development
> DDI +64 3 962 2639 | Fax +64 3 962 6220
> www.med.govt.nz
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Robin Buyer
> Sent: Friday, 23 December 2005 11:50 a.m.
> To: Tutor@python.org
> Subject: [Tutor] running a .exe
>
>
> How do you run a .exe from inside a python program.
> random example:
> print "What would you like to do today? "
> print "E - email"
> print "I - internet"
> what = input("Choose: ")
> if what == "E":
> Heres where i would need to run IEXPLORE.exe
>
> A new monthly electronic newsletter covering all aspects of MED's work is
now available.  Subscribers can choose to receive news from any or all of
seven categories, free of charge: Growth and Innovation, Strategic
Directions, Energy and Resources, Business News, ICT, Consumer Issues and
Tourism.  See http://news.business.govt.nz for more details.
>
>
>
>
> http://www.govt.nz - connecting you to New Zealand central & local
government services
>
> Any opinions expressed in this message are not necessarily those of the
Ministry of Economic Development. This message and any files transmitted
with it are confidential and solely for the use of the intended recipient.
If you are not the intended recipient or the person responsible for delivery
to the intended recipient, be advised that you have received this message in
error and that any use is strictly prohibited. Please contact the sender and
delete the message and any attachment from your computer.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] running a .exe

2005-12-22 Thread Kent Johnson
Robin Buyer wrote:
> How do you run a .exe from inside a python program.
> random example:
> print "What would you like to do today? "
> print "E - email"
> print "I - internet"
> what = input("Choose: ")
> if what == "E":
> Heres where i would need to run IEXPLORE.exe

Look at os.system() (simple) and the subprocess module (more complicated and 
flexible).

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] running a .exe

2005-12-22 Thread Robin Buyer



How do you run a .exe from inside a python 
program.
random example:
print "What would you like to do today? 
"    print "E - email"    print "I - 
internet"    what = input("Choose: ")    
if what == "E":
        Heres where i 
would need to run IEXPLORE.exe 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor