Différences entre gawk et les autres awk

Différences entre gawk et les autres awk - Shell/Batch - Programmation

Marsh Posté le 17-05-2009 à 15:23:04    

Bonjour,
J'ai un script écrit pour gawk qui fonctionne très bien mais lorsque que je veux l'exécuter sur une machine (AIX-IBM) ayant uniquement awk (ou mwak) le script ne fonctionne plus.
Vous avez une idée des adaptations a faire pour le rendre compatible?
Je ne trouve pas les différences entre les différentes "version" d'AWK
 
Le script :  
 

Code :
  1. function parseCreate(t) {
  2.    match(t, /^CREATE TABLE : ([^;[:space:]]+);([^[:space:]]+) AS$/, a)
  3.    if ( 2 in a ) {
  4.       Program = a[1]
  5.       Table = a[2]
  6.    }
  7. }
  8. function parseSelect(t) {
  9.    match(t, /^SELECT : ([^;[:space:]]+);([^[:space:]]+)$/, a)
  10.    if ( 2 in a ) {
  11.       if ( a[1] == Program ) {
  12.      delete Select
  13.          split(a[2], Select, "," )
  14.       }
  15.    }
  16. }
  17. function parseFrom(t) {
  18.    match(t, /^FROM : ([^;[:space:]]+);([^;]+)$/, a)
  19.    if ( 2 in a ) {
  20.       if ( a[1] == Program ) {
  21.      split(a[2], b, "," )
  22.          delete From
  23.          for ( n in b ) {
  24.             match(b[n], /([^[:space:]]+) ([^[:space:]]+)/, a)
  25.             if (2 in a) {
  26.                From[a[2]] = a[1]
  27.             } else {
  28.                From[0] = b[n]
  29.             }
  30.          }
  31.       }
  32.    }
  33. }
  34.  
  35. BEGIN {
  36.    Program = "MISSING"
  37. }
  38.  
  39. /^CREATE/ { parseCreate($0) }
  40. Program != "MISSING" {
  41.    if ($0 ~ /^SELECT/) {
  42.       parseSelect($0)
  43.    }
  44.    if ($0 ~ /^FROM/) {
  45.       parseFrom($0)
  46.       for (n in Select) {
  47.          match(Select[n], /([^.]+)\.([^.]+)/, a)
  48.          if ( 2 in a ) {
  49.             print Program,";",Table,";",From[a[1]],";",a[2]
  50.          } else {
  51.             print Program,";",Table,";",From[0],";",Select[n]
  52.          }
  53.       }
  54.       Program = "MISSING"
  55.    }
  56. }


 
Merci d'avance

Reply

Marsh Posté le 17-05-2009 à 15:23:04   

Reply

Marsh Posté le 17-05-2009 à 15:47:53    

Tout est dans le manuel officiel de gawk [:spamafote]

 

http://www.gnu.org/manual/gawk/htm [...] IX_002fGNU
http://www.gnu.org/manual/gawk/htm [...] Extensions


Message édité par masklinn le 17-05-2009 à 15:49:56

---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 18-05-2009 à 16:27:09    

Oui merci, donc apparement c'est essentiellement la fonction match qui n'est présente que dans gawk.
Vous voyez comment faire pour la remplacer?

Reply

Marsh Posté le 18-05-2009 à 17:21:32    

En faite je ne sais pas lire...
La fonction est match existe bien mais pas le 3ème paramètre (optionnel) dont je me sert dans le script...

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed