0
$ python -i test.py
系统找不到指定的路径。(system could not find the path)
>>> Stopped

$ cat test.py
#!/usr/bin/python
import os
cmd = "ls -l >/dev/null 2>&1"
os.system(cmd)

When I use standard output redirection in Python with gitbash, it just doesn't work, while it just works well when running the command directly in gitbash.

$ ls -l >/dev/null 2>&1

Is there anyone that has met this problem or might help?

snwflk
  • 3,341
  • 4
  • 25
  • 37
  • Possible duplicate of [Redirecting stdio from a command in os.system() in Python](https://stackoverflow.com/questions/3197509/redirecting-stdio-from-a-command-in-os-system-in-python) – snwflk Jun 05 '19 at 14:45

1 Answers1

0

I find the root cause under the link bellow, hope it might help more https://superuser.com/questions/777198/equivalent-of-foo-dev-null-in-windows-shell