I need to get IP addresses witch connected to my server on port on Ubuntu (for exmp: 5809). For example in Ubuntu we have terminal command like this:
netstat -tn 2>/dev/null | grep :5809 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
Output results after this command:
How to realize analog of this function in C# Mono Ubuntu ? I hope for your help..
tezaurismosis - answered me in another forum, i'l thanks him.
var proc = new Process {
StartInfo = new ProcessStartInfo {
FileName = @"netstat -tn 2>/dev/null | grep :80| awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream) {
// каждая строка вывода
string line = proc.StandardOutput.ReadLine();
}