 | 
September 8th, 2008, 08:36 PM
| | Newbie | | Join Date: Sep 2008
Posts: 5
| | os.system()
Hi,
I am tryting to invoke an application that is located at:
"P:\P_NS0\tools\tpprogV27k.exe"
I am only using the following the following code:
import os
os.system("P:\P_NS0\tools\tpprogV27k.exe");
I get the following error:
'P:\P_NS0' is not recognized as an internal or external command,
operable program or batch file.
If I type the same code in PythonWin I get the following:
>>> os.system("P:\P_NS0\tools\tpprogV27k.exe");
1
Please help me I am a new pyhton user any help is greatly appreciated.
| 
September 8th, 2008, 09:41 PM
|  | Expert | | Join Date: Mar 2008 Location: ♩♫♬♪♩
Posts: 380
| |
Hi,
Do you know about escape sequences? If a character in a string has a backslash in front of it, it and the backslash are treated as one special character. I think this may be the source of your problem. If you put two backslashes in a row, they are treated as a single backslash. Try that and see if it helps.
Good luck.
| 
September 8th, 2008, 10:29 PM
| | Newbie | | Join Date: Sep 2008
Posts: 5
| | Quote: |
Originally Posted by boxfish Hi,
Do you know about escape sequences? If a character in a string has a backslash in front of it, it and the backslash are treated as one special character. I think this may be the source of your problem. If you put two backslashes in a row, they are treated as a single backslash. Try that and see if it helps.
Good luck. | Thanks for the help,
I tried the following and I got these:
>>> os.system("c:/")
1
>>> os.system("c:/")
1
>>> os.system("P:/")
1
>>> os.system("c:")
0
>>> os.system("P:")
but neither C: nor P: drive opened
| 
September 9th, 2008, 12:22 AM
|  | Expert | | Join Date: Mar 2008 Location: ♩♫♬♪♩
Posts: 380
| |
If you're using windows, and you want to open those drives with Windows Explorer, use the explorer command: - os.system("explorer \"c:\\\")
(the backslashes before the quotes differentiate them from the end of the string).
If you want to change the active directory to one of those drives, use the chdir function:
Or are you trying to do something else?
| 
September 9th, 2008, 08:41 AM
| | Newbie | | Join Date: Sep 2008
Posts: 8
| |
have you tried this -
>>os.system(r"P:\P_NS0\tools\tpprogV27k.exe");
in case you missed the change, there is an extra 'r' (meaning raw), before specifying the string.
-
shreyas
| 
September 9th, 2008, 03:55 PM
| | Newbie | | Join Date: Sep 2008
Posts: 5
| | Quote: |
Originally Posted by shreyask have you tried this -
>>os.system(r"P:\P_NS0\tools\tpprogV27k.exe");
in case you missed the change, there is an extra 'r' (meaning raw), before specifying the string.
-
shreyas | Thank you shreyas it worked :)
| 
September 9th, 2008, 04:35 PM
| | Newbie | | Join Date: Sep 2008
Posts: 5
| | Quote: |
Originally Posted by rami823 Thank you shreyas it worked :) |
hi,
I have now another problem,
I am opening two programs using two
os.system() commands but the problem is that the second program does not open unless I close the first one.
It does not matter which program comes first
thank you all for the support
Ram
| 
September 9th, 2008, 09:09 PM
| | Expert | | Join Date: Sep 2007
Posts: 846
| |
Right. System() does not return to Python until after the program run with it exits. If you want it to run separately, look up the os.exec family of functions after creating a separate process with os.fork().
Documentation for both can be found on the Internet, but will most likely refer to the C versions these are wrappers for.
| 
September 11th, 2008, 03:20 PM
| | Newbie | | Join Date: Sep 2008
Posts: 5
| | Quote: |
Originally Posted by Laharl Right. System() does not return to Python until after the program run with it exits. If you want it to run separately, look up the os.exec family of functions after creating a separate process with os.fork().
Documentation for both can be found on the Internet, but will most likely refer to the C versions these are wrappers for. |
I learned from little research that the function os.fork() does not work on microsoft windows and it only works on linux.
| 
September 11th, 2008, 09:17 PM
| | Expert | | Join Date: Sep 2007
Posts: 846
| |
That is likely because the C version is a *nix system call...I figured the Python guys would have set up a wrapper to a similar Windows system call, CreateProcess. You've reached the end of my knowledge of Windows-specific Python, I'm afraid...
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|