Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem migrating awk from HP to Solaris 8

Status
Not open for further replies.

mpflug

Programmer
Aug 6, 2002
2
US
We recently migrated an awk script to Solaris 8 from HP. We are now receiving errors when running the script. The awk script is called by a shell script which passes data to the awk script to be formatted and displayed. We’ve tried code modifications, and changing to gawk or nawk, which eliminate the errors, but the data is not displayed. Any help is greatly appreciated.
Code:
#!/usr/bin/awk -f
/id|ver|os|osver|step|eend|done/ {
  x[$1]=$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9;
  gsub(/  /,"",x[$1]);
  sub(/ $/,"",x[$1]);
  if ($1 == "done") {
    if (header_done == 0) {
    printf("\nBug is fixed in\n");
    printf("%-5s %-12s %-20s %-20s %-10s %-10s\n", "ID#", "Version", "OS", "St
ep", "Est end", "Done");
    header_done = 1;
  }
    printf("%5d %-12s %-20s %-20s %-10s %-10s\n", x["id"], x["ver"], x["os"]" "x
["osver"], substr(x["step"],1,20), x["eend"], x["done"]);
  }
}
Error Messages:

awk: syntax error near line 4
awk: illegal statement near line 4
awk: syntax error near line 5
awk: illegal statement near line 5

Data:

id 1
ver 1
os UNIX
osver 7
step ABC
eend 01/01/2000
done
 
works fine changing to nawk:

#!/usr/bin/nawk -f vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Hi vlad,

I just tried using nawk again, and this is the error we're getting:

/usr/bin/nawk: syntax error at source line 16
context is
ver >>> 7.30. <<< R1.2
/usr/bin/nawk: bailing out at source line 16

I'm only running the awk with the following command:

a.awk -f a.out

When I look at the code, there is no line 16 in the awk script. I know I'm missing something, but I'm not that familiar with awk. Any ideas?

Thanks for your help!
 
I presume your awk script [as in above] is in a.awk and your data file is in a.out

Run as the following [with the change to nawk in a.awk]:

a.awk a.out vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top