0

I'm trying to run the following command to process the output via Swift 2.0 but I'm having trouble doing so.

netstat -w1 -I en | awk '{ print $3 }'

The command runs as expected when ran manually from the terminal.

I tried the method of calling /bin/sh -c with the full command as an argument but that doesn't output anything. (Similar to https://stackoverflow.com/a/29549342/2110967).

I also tried to pass the data over stdout/stdin from the netstat to the awk but didn't have much luck.

I also tried placing the code into a .sh file and running from there but again the output was never returned.

Community
  • 1
  • 1
chrisdwheatley
  • 127
  • 1
  • 10
  • Replace `awk '{ print $3 }'` with `cat`. Do you still have a problem? If so it's nothing to do with awk so focus on your netstat and swift (whatever that is) commands/environments. – Ed Morton Sep 14 '15 at 23:42
  • No the problem doesn't occur when I replace the awk with something else. It seems to be an issue with `awk` in NSTask (https://stackoverflow.com/questions/1250344/using-awk-with-nstask). I need to be able to pull out a dynamic value from what netstat returns, if anyone knows a way to do this without using awk that's be perfect – chrisdwheatley Sep 15 '15 at 09:12

0 Answers0