2

On Windows, the python subprocess command to open a cmd window is simply:

import subprocess
subprocess.Popen('cmd.exe')

Can anyone tell me what the command to open the cmd equivalent in Linux is? I'm going to be copying some python code from my Windows machine to my Raspberry Pi and am new to Linux - I know that this line of code won't open the terminal on a Linux OS the same way it will on Windows.

Thanks in advance!

1
  • 1
    Just out of curiosity, what is the end goal of doing this? Usually, you pass shell=True to execute shell commands from Python. I recognize that might not be your end-goal, however, so that might not be helpful to you. Commented Apr 30, 2020 at 23:13

2 Answers 2

5

Replace cmd.exe with gnome-terminal in order to open a terminal on Linux

Sign up to request clarification or add additional context in comments.

2 Comments

Or xfce4-terminal on XFCE or konsole on KDE, etc.
Yes, I was assuming that @Olivier Holland was using a standard distribution ;)
1

Different distros use different terminal programs. xterm should work on just about everything, so you could Popen('xterm') and then require the people figure out how to get xterm on their system if its not there by default.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.