Erro de sintaxe no programa awk

1

Eu quero verificar o método de atribuição de IP como em pergunta. Eu estou correndo em bash no Ubuntu 12.04. Meu problema é a função "get_con_id ()" me dá "Erro de sintaxe" na cláusula if. O script é o seguinte (não modificado da resposta da pergunta dada):

 #!/bin/sh

 # get the connection id of the active connection    
 get_con_id() {
   nm-tool |
     awk '
       $1 == "-" {
         dev = $3
         id = dev
         if (NF > 4 && match($0, "\[(.*)\]", a))
           id = a[1]
       }
       /^ / && $1 == "State:" && $2 == "connected" {
         print id
       }'
 }

 # get the address type of the active connection
 nmcli con list id "$(get_con_id)" |
   awk '
     $1 == "ipv4.method:" {
       if ($2 == "manual")
         print "static"
       else if ($2 == "auto")
         print "dynamic"
       else
         print "unknown"
     }'
    
por PdXY 16.12.2013 / 10:13

1 resposta

1

Você está usando mawk , mas esse script exige gawk .

sudo apt-get install gawk

Ele redefinirá automaticamente awk para gawk para que o script funcione. Se ele não for redefinido, altere todos os awk no script para gawk .

    
por falconer 16.12.2013 / 12:19