9

I have installed PyCharm to using Python language on Windows 10.

I'm trying to execute command from Linux command in PyCharm, I used this code:

import subprocess
subprocess.run("cat",shell=True,text=True)

But I get this error:

'cat' is not recognized as an internal or external command, operable program or batch file.

I want to execute several commands another such as this example, but all commands raise the same error. How to solve this?

2
  • 5
    cat isn't a windows/DOS program. In other words, if you type cat into the CMD prompt directly, you'll get the same result. In that sense, your python script is working as desired. Commented Jan 15, 2021 at 1:07
  • 2
    If running a command on Windows or running a command on Linux you have to use different approaches. Your example would run on Linux but has to be changed to run on Windows. Commented Jan 15, 2021 at 9:02

1 Answer 1

2

Cat is a binary included in Unix systems, since windows isn't based on Unix, it wouldn't work. You should rather try the TYPE command in Windows

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.