473,508 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to launch cmd window, and excute command within the cmd window with Python script

2 New Member
I want to write a Python script to do following:
1. launch cmd window
2. execute dos command within cmd window.

I tried following:

command = r'start "test" cmd'
os.system(command)

=> it is able to launch a cmd window with "test" title.

What is the syntax for not only launch the cmd window, but also able to execute a command, like run a python script.

I tried to do
command = r 'start "test" cmd ("dir")'
- expect it launch the cmd window, and excute "dir" command, doesn't work.
Sep 20 '10 #1
2 2294
dwblas
626 Recognized Expert Contributor
Try Pexpect, a Python module written to run programs and watch their output from Python.
Sep 20 '10 #2
vivawind
2 New Member
Before I spend time studying the Pexpect as you mentioned, wondering if this works well under Window's environment. If not, what will be the solution?
Oct 5 '10 #3

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

Similar topics

3
48752
by: Tubby Tudor | last post by:
What is the best way to call one python script from within another python script? For example: one.py finishes succesfully and calls two.py which finishes OK and then calls three.py Thanks...
0
1774
by: adder | last post by:
I would like to create a script that can export ai-files to jpg-files using the export function available in Adobe Illustrator. Can someone tell me how to dispatch the illustrator com-object to...
3
3540
by: olaufr | last post by:
Hi, I need to call a python script, with command line arguments (it is an autonomous script with a __main__), from within another python script. Can I use exec() or execfile() for this? How to...
7
12989
by: Pankaj | last post by:
The module which i am creating is like Part A: 1. It does some processing by using python code. 2. The result of this python code execution is written to a text file. ] Part B: 1. I read a...
1
1674
by: dfaber | last post by:
Aloha! I want to terminate a process/program from within a python script. For example, if I have a program say foo.sh that starts running, then I can run it from within a python script using...
5
10447
by: Efrat Regev | last post by:
Hello, I need to call GNU/make from within a Python script. This raised some problems: 1. The script is not in the directory of the makefile, and changing the locations of either is not an...
2
9239
by: Viewer T. | last post by:
I am trying to write a script that deletes certain files based on certain criteria. What I am trying to do is to automate the process of deleting certain malware files that disguise themselves...
2
2143
by: Henry Hollenberg | last post by:
Hello, I have written a script that uses environment variables set during a particular users login in ".bash_profile" and ".profile". I have changed to that users uid and gid in my python...
2
4739
by: gintrado | last post by:
I am very new to Python I'm trying to run a python script from within another python script. I can run the script from a unix command line by typing: nohup python script.py password >...
0
7225
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
7123
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
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7046
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
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
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...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.