Command Prompt

L

Lee Harr

Is there any way of using Python to open a command prompt?

Almost certainly going to depend on your system.
I would use ...


import os
os.system('xterm &')
 
T

Terry Reedy

EAS said:
Is there any way of using Python to open a command prompt?

You may need to be more specific. On various versions of Windows, in batch
or interactive mode, os.system('command.com') might or might not do what
you want. On Win XP, interactive mode, one is already in a command window
and the above gives a command prompt 'C:/Python...' in the same window,
where one can do dir, cd, type, etc, and finally exit to return to Python
and its prompt (again in the same window).

Terry J. Reedy
 
E

EAS

Depend on the operating system or the computer? The two OS I use are Windows
XP Pro and
Windows NT 2000 Pro.
 
P

Peter Hansen

Terry said:
You may need to be more specific. On various versions of Windows, in batch
or interactive mode, os.system('command.com') might or might not do what
you want. On Win XP, interactive mode, one is already in a command window
and the above gives a command prompt 'C:/Python...' in the same window,
where one can do dir, cd, type, etc, and finally exit to return to Python
and its prompt (again in the same window).

Minor issue: on Win XP, there is a "command" and a "cmd". Here's
the visible difference between the two:

c:\>cmd
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>command
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

Presumably there are other, more significant differences as well.

Probably advisable to use "cmd" under WinXP, but that's just a hunch.

-Peter
 
M

Michael Geary

Peter said:
Minor issue: on Win XP, there is a "command" and a "cmd".
Here's the visible difference between the two:

c:\>cmd
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>command
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

Presumably there are other, more significant differences
as well.

Probably advisable to use "cmd" under WinXP, but that's
just a hunch.

There's a huge difference between the two. cmd.exe is a 32-bit console
application, and command.com is a 16-bit DOS application. You definitely
want cmd.exe on the NT versions of Windows (NT, 2000, XP).

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top