stagebi | 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 :
- function parseCreate(t) {
- match(t, /^CREATE TABLE : ([^;[:space:]]+);([^[:space:]]+) AS$/, a)
- if ( 2 in a ) {
- Program = a[1]
- Table = a[2]
- }
- }
- function parseSelect(t) {
- match(t, /^SELECT : ([^;[:space:]]+);([^[:space:]]+)$/, a)
- if ( 2 in a ) {
- if ( a[1] == Program ) {
- delete Select
- split(a[2], Select, "," )
- }
- }
- }
- function parseFrom(t) {
- match(t, /^FROM : ([^;[:space:]]+);([^;]+)$/, a)
- if ( 2 in a ) {
- if ( a[1] == Program ) {
- split(a[2], b, "," )
- delete From
- for ( n in b ) {
- match(b[n], /([^[:space:]]+) ([^[:space:]]+)/, a)
- if (2 in a) {
- From[a[2]] = a[1]
- } else {
- From[0] = b[n]
- }
- }
- }
- }
- }
-
- BEGIN {
- Program = "MISSING"
- }
-
- /^CREATE/ { parseCreate($0) }
- Program != "MISSING" {
- if ($0 ~ /^SELECT/) {
- parseSelect($0)
- }
- if ($0 ~ /^FROM/) {
- parseFrom($0)
- for (n in Select) {
- match(Select[n], /([^.]+)\.([^.]+)/, a)
- if ( 2 in a ) {
- print Program,";",Table,";",From[a[1]],";",a[2]
- } else {
- print Program,";",Table,";",From[0],";",Select[n]
- }
- }
- Program = "MISSING"
- }
- }
|
Merci d'avance |