0

This doesn't work and says that there's no such file or directory

current_conecctions = subprocess.Popen("netstat -p udp",shell = False, stdout=subprocess.PIPE).stdout.read()

While netstat -p udp works perfectly in the terminal.

Esteban Vargas
  • 512
  • 1
  • 6
  • 24
  • You probably want to avoid `Popen` anyway; see https://stackoverflow.com/questions/4256107/running-bash-commands-in-python – tripleee Oct 23 '18 at 03:33

1 Answers1

6

Try to use a list of parameters instead of a single string:

command = ["netstat", "-p", "udp"]
current_conecctions = subprocess.Popen(command, shell = False, stdout=subprocess.PIPE).stdout.read()
Hemerson Tacon
  • 2,419
  • 1
  • 16
  • 28