473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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.
Sep 8 '08 #1
9 1576
boxfish
469 Expert 256MB
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.
Sep 8 '08 #2
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
Sep 8 '08 #3
boxfish
469 Expert 256MB
If you're using windows, and you want to open those drives with Windows Explorer, use the explorer command:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. os.chdir("c:\\")
Or are you trying to do something else?
Sep 8 '08 #4
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
Sep 9 '08 #5
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 :)
Sep 9 '08 #6
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
Sep 9 '08 #7
Laharl
849 Expert 512MB
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.
Sep 9 '08 #8
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.
Sep 11 '08 #9
Laharl
849 Expert 512MB
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...
Sep 11 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
2
by: Scott | last post by:
Not sure if this is the right place to post this or not, but I am in the process of trying to find a Web Hosting/Isp Billing system that is reasonable in price and uses Access or SQL Server for a...
0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.