'netstat -in -f inet|awk ''{ print $1,"\t",$3,"\t",$4; }''|grep -v -e lo0 -e enc -e pflog -e tun|grep Link|sed ''s/*//''|awk ''{ if( system("[ ! -f /var/run/dmesg.boot ]") == 0) system("dmesg >/var/run/dmesg.boot"); cmd="grep ^"$1" /var/run/dmesg.boot"; while((cmd|getline drv0)>0) {$4=drv0} close(cmd); print $1,"\t",$3,"\t",$4;}''
It works, but ... I seek the way to run it using function offred by process unit.
First, the way the original command is constructed, you'll need to feed it to a shell. Each of the awk, grep, sed etc is a process by itself. To run the script without shell, your program will have to do what the shell does: fork/exec each process and join up their stdin/stdout using pipes, i.e., work like a shell. So might as well just use the shell to run your script.
Second, it should be possible to write a single awk program that does all the awk/grep/sed stuff so your process pipeline should simply be <netstat output> | <single awk program>. And from
there, you could implement what the single awk program does in Pascal.
Then, you could use TProcess to run the netstat command and process its output in your Pascal program.
But I have a question: Why not just run t.sh? Why replicate the work in Pascal?