我写了一个awk脚本,从file.txt的和这个文件的每一行进行调用system("...")
需要一定的值。 问题是,终端只接受最后一次系统调用。系统(“”)调用
我需要每调用一次system("...")
呼叫,我的file.txt
的每一行都会被执行。
例如: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
例如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 i need to have the execution of the system call
}
你为什么要把它放在'awk'中? – pfnuesel
你想运行的实际'curl'命令是什么 - 你能举一个没有awk所需的可怕引号的例子吗? –
在AWK中,将两个字符串相邻放置是字符串连接。所以这些报价都不需要;他们什么都不做,只是混淆了代码。 – e0k