[Tutor] Executing a program from within a Python Program

Bob Gailer ramrom@earthling.net
Fri Mar 14 12:23:01 2003


--=======7694C21=======
Content-Type: multipart/alternative; x-avg-checked=avg-ok-48D13BA; boundary="=====================_9924220==.ALT"


--=====================_9924220==.ALT
Content-Type: text/plain; x-avg-checked=avg-ok-48D13BA; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 10:37 AM 3/14/2003 -0600, Henry Steigerwaldt wrote:
>[snip]
>when I attempt to start a program like Paint Shop Pro that
>is NOT part of Windows, I get an error that Python cannot
>find the program, examples:
>
>      import os
>      os.system("start c:\\program files\\jasc software inc\\paint shop pro
>7\\psp.exe")

Try os.system("c:\\program files\\jasc software inc\\paint shop pro7\\psp.exe")

MORE LATE BREAKING NEWS:

Did you read the error message? I'll bet it said Cannot find the file 
'c:\\program files\\jasc' (or one.... Notice that the first blank in the 
path is seen as the end of the program. If you were entering this command 
at at DOS prompt you'd need to put it in "" to have the OS take the entire 
path name. So let's put it in quotes:
os.system('start "c:\\program files\\jasc software inc\\paint shop 
pro7\\psp.exe"')
Which gives us a DOS window with c:\program files\jasc software inc\paint 
shop pro7\\psp.exe in the title bar!

Look up start in help:

Starts a separate window to run a specified program or command.
start ["title"] [/dpath] [/i] [/min] [/max] [/separate| /shared] 
[/low|/normal|/high|/realtime] [/wait] [/b] [filename] [parameters]

So the first quoted string is taken as the title. That leads to:

os.system('start "arbitrary title" "c:\\program files\\jasc software 
inc\\paint shop pro7\\psp.exe"')

and Bob's your Uncle.

Bob Gailer
mailto:ramrom@earthling.net
303 442 2625


--=====================_9924220==.ALT
Content-Type: text/html; x-avg-checked=avg-ok-48D13BA; charset=us-ascii
Content-Transfer-Encoding: 8bit

<html>
<body>
At 10:37 AM 3/14/2003 -0600, Henry Steigerwaldt wrote:<br>
<blockquote type=cite class=cite cite>[snip]<br>
when I attempt to start a program like Paint Shop Pro that<br>
is NOT part of Windows, I get an error that Python cannot<br>
find the program, examples:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp; import os<br>
&nbsp;&nbsp;&nbsp;&nbsp; os.system(&quot;start c:\\program files\\jasc
software inc\\paint shop pro<br>
7\\psp.exe&quot;)</blockquote><br>
Try os.system(&quot;c:\\program files\\jasc software inc\\paint shop
pro7\\psp.exe&quot;)<br><br>
MORE LATE BREAKING NEWS:<br><br>
Did you read the error message? I'll bet it said Cannot find the file
'c:\\program files\\jasc' (or one.... Notice that the first blank in the
path is seen as the end of the program. If you were entering this command
at at DOS prompt you'd need to put it in &quot;&quot; to have the OS take
the entire path name. So let's put it in quotes:<br>
os.system('start &quot;c:\\program files\\jasc software inc\\paint shop
pro7\\psp.exe&quot;')<br>
Which gives us a DOS window with c:\program files\jasc software inc\paint
shop pro7\\psp.exe in the title bar!<br><br>
Look up start in help:<br><br>
Starts a separate window to run a specified program or command.<br>
<b>start</b> [<b>&quot;</b><i>title</i><b>&quot;</b>]
[<b>/d</b><i>path</i>] [<b>/i</b>] [<b>/min</b>] [<b>/max</b>]
[<b>/separate| /shared</b>]
[<b>/low</b>|<b>/normal</b>|<b>/high</b>|<b>/realtime</b>] [/<b>wait</b>]
[<b>/b</b>] [<i>filename</i>] [<i>parameters</i>]<br><br>
So the first quoted string is taken as the title. That leads 
to:<br><br>
os.system('start &quot;arbitrary title&quot; &quot;c:\\program
files\\jasc software inc\\paint shop pro7\\psp.exe&quot;')<br><br>
and Bob's your Uncle.<br>
<x-sigsep><p></x-sigsep>
Bob Gailer<br>
<a href="mailto:ramrom@earthling.net" eudora="autourl">mailto:ramrom@earthling.net</a><br>
303 442 2625<br>
</body>
</html>


--=====================_9924220==.ALT--

--=======7694C21=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-48D13BA
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.459 / Virus Database: 258 - Release Date: 2/25/2003

--=======7694C21=======--