system("") call in AWK executing only last line -
i have written awk script takes values file.txt , each row of file makes call system("...")
. problem terminal takes last system call.
i need every system("...")
call being called each row of file.txt
gets executed.
for example: file.txt
00:00:6c:19:8f:b1:d8:27 10.0.0.10 1 00:00:6c:19:8f:b1:d8:27 10.0.0.11 1 00:00:6c:19:8f:b1:d8:28 10.0.0.12 3 00:00:6c:19:8f:b1:d8:28 10.0.0.11 2
for example file.awk:
begin { } { switch_mac=$1 ip_dst=$2 output_port=$3 system("curl" " -d" " '{" "\"switch\""":" "\""switch_mac"\"""," "\"cookie\""":""\"1\"""," "\"priority\""":""\"2\"""," "\"eth_type\""":""\"0x0800\"""," "\"ipv4_dst\""":""\""ip_dst"\"""," "\"active\""":""\"true\"""," "\"actions\""":""\"output="output_port"\"""}'" " http://10.0.0.11:8080/wm/staticflowpusher/json") //here need have execution of system call }
you're calling external process once per line anyway speedup might expect see using awk read file isn't worth worrying about:
while read -r switch_mac ip_dst output_port; # curl command "$switch_mac", "$ip_dst" , "$output_port" (include quotes!) done < file.txt
you can capture response using output=$(curl ...)
if desire, or pipe output of loop awk if want.
Comments
Post a Comment