0

I tried using some Unix command using the subprocess module on my Python interpreter installed on a windows 7 OS. However, it errors out saying command not found. It does recognize Windows commands though. Can I somehow use Unix commands in here too?

Thanks, Vishal

3
  • >>> subprocess.call('pwd',shell=True) 'pwd' is not recognized as an internal or external command, operable program or batch file. 1 Commented Nov 14, 2014 at 21:22
  • >>> subprocess.call('dir',shell=True) Volume in drive C is OSDisk Volume Serial Number is 90CF-90DB Directory of C:\Python34 11/14/2014 11:38 AM <DIR> . 11/14/2014 11:38 AM <DIR> .. 11/14/2014 11:38 AM <DIR> DLLs 11/14/2014 11:38 AM <DIR> Doc 11/14/2014 11:38 AM <DIR> include 11/14/2014 11:38 AM <DIR> Lib ... Commented Nov 14, 2014 at 21:24
  • You can't run "linux" commands on Windows. Just like you can call Windows commands on linux. You'll need to add something in the middle. For instance cygwin. Commented Nov 14, 2014 at 21:25

2 Answers 2

4

You can't run a command that's not there. There are multiple options for obtaining POSIX/GNU commands for Windows, including Git Bash, MSYS/MinGW, Cygwin, etc.

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

2 Comments

Allright, thanks. I thought there could be a bash module in python itself I could use. Doesn't look like it. Thanks anyways
@user3399273 no problem. If my answer helped solve your problem, please consider indicating that by clicking the check mark next to the answer. It marks your question as resolved, and generates reputation points for both of us. See How does accepting an answer work? for more information.
0

You have to install Unix Bash for Windows, but not sure if it works correctly ... Better solution is install or virtualize some Linux distribution.

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.