Illegal Statement at source line 2

Hello

I'm pretty new to Shell Programming and I'm trying to write a script to display the out of a file displaying licence-use for an application. I've piped the output of my licence-use query to a file. On this file I am trying to run the following awk file, but I keep getting the error:

bash-3.00$ nawk -f ~/viewlicences.awk ~/licences

nawk: syntax error at source line 2
context is
if ($0 /Users of >>> SYNERGY-CMBase/) <<<
nawk: illegal statement at source line 2

This is my awk script that I'm trying to run on the file:

1 {
2 if ($0 [/Users of SYNERGY-CMBase/])
3 {
4 while ("x" == "x")
5 {
6 getline var
7 if (var == "") { continue }
8 if (var != /Users of SYNERGY-GroupSecurity/) { print var } else { exit }
9 }
10 }
11 }

I'm basically trying to capture output between the line which which says "Users of SYNERGY-CMBase" and Users of "SYNERGY-GroupSecurity".

Any advice would be greatly appreciated. :b:

Your line 2 does not appear to be of proper syntax. Are you trying to say
if $0=="/Users of >>> SYNERGY-CMBase/"

Otherwise, can you attach a section of the file you are trying to read a line from?

Here's the file I'm trying to read from. I'm wanting to display output from line 26 up until before line 36...

1 lmutil - Copyright (c) 1989-2006 Macrovision Europe Ltd. and/or Macrovision Corporation. All Rights Reserved.
2 Flexible License Manager status on Mon 1/19/2009 13:06
3
4 License server status: ##########
5 License file(s) on #############:
6
7 #########: license server UP (MASTER) v10.8
8
9 Vendor daemon status (on ########):
10
11 telelogic: UP v10.8
12
13 Feature usage info:
14
15 Users of Telelogic_Support: (Total of 1000 licenses issued; Total of 0 licenses in use)
16
17 Users of SYNERGY-ActiveCM: (Total of 10 licenses issued; Total of 0 licenses in use)
18
19 Users of SYNERGY-ChangeBase: (Total of 11 licenses issued; Total of 1 license in use)
20
21 "SYNERGY-ChangeBase" v2009.1230, vendor: telelogic
22 floating license
23
24 ccm_root phys-agsdev /dev/tty ChangeAdmin (v1.0) (Phys-agsdev/19353 580), start Mon 1/19 6:30 (linger: 1800)
25
26 Users of SYNERGY-CMBase: (Total of 12 licenses issued; Total of 4 licenses in use)
27
28 "SYNERGY-CMBase" v2009.1230, vendor: telelogic
29 floating license
30
31 ccm_root phys-agsdev /dev/tty z000798 (v1.0) (Phys-agsdev/19353 436), start Mon 1/19 10:54
32 ccm_root phys-agsdev /dev/tty z001383 (v1.0) (Phys-agsdev/19353 2014), start Mon 1/19 11:22
33 ccm_root phys-agsdev /dev/pts/10 u025027 (v1.0) (Phys-agsdev/19353 794), start Mon 1/19 9:54
34 ccm_root phys-agsdev /dev/pts/27 u414020 (v1.0) (Phys-agsdev/19353 273), start Mon 1/19 12:02
35
36 Users of SYNERGY-GroupSecurity: (Total of 20 licenses issued; Total of 0 licenses in use)
37
38 Users of SYNERGY-ObjectMake: (Total of 10 licenses issued; Total of 0 licenses in use)
39
40 Users of SYNERGY-OracleSupport: (Total of 1 license issued; Total of 0 licenses in use)
41

1) Does your file normally have line numbers, or is that something you added to make it easier to read?
2) Always at line 26, or just in this example?

No, I just put them in for the sake of readability. The line numbers themselves are largely irrelevant because depending on the number of licences in use, there may be more less entries in the file for each licence type.

> cat manip144.sh
# set filename
myf="file144"

# find first line
stlin=`cat -n ${myf} | grep "Users of SYNERGY-CMBase" | awk '{print $1}' `
#echo ${stlin}
# find ending line
enlin=`tail +${stlin} ${myf} | cat -n | grep "Users of SYNERGY-GroupSecurity" | awk '{print $1}' `
#echo ${enlin}

tail +${stlin} ${myf} | head -${enlin}


> manip144.sh
26 Users of SYNERGY-CMBase: (Total of 12 licenses issued; Total of 4 licenses in use)
27
28 "SYNERGY-CMBase" v2009.1230, vendor: telelogic
29 floating license
30
31 ccm_root phys-agsdev /dev/tty z000798 (v1.0) (Phys-agsdev/19353 436), start Mon 1/19 10:54
32 ccm_root phys-agsdev /dev/tty z001383 (v1.0) (Phys-agsdev/19353 2014), start Mon 1/19 11:22
33 ccm_root phys-agsdev /dev/pts/10 u025027 (v1.0) (Phys-agsdev/19353 794), start Mon 1/19 9:54
34 ccm_root phys-agsdev /dev/pts/27 u414020 (v1.0) (Phys-agsdev/19353 273), start Mon 1/19 12:02
35
36 Users of SYNERGY-GroupSecurity: (Total of 20 licenses issued; Total of 0 licenses in use)

Note that I simply copied your sample text file; hence the line numbers still being there.

Joeyg, many thanks for your help. Just before you had posted that, I changed my script to:

if ($0 ~ /Users of SYNERGY-CMBase:/) {print}
if ($0 ~ /"SYNERGY-CMBase"/)
{
while ("x" == "x")
{
getline var
if (var ~ /floating license/) {continue}
if (var == "") { continue }
if (var !~ /Users of SYNERGY-GroupSecurity/) {print var} else {exit}
}
}
}

which gives me the output:

Users of SYNERGY-CMBase: (Total of 12 licenses issued; Total of 3 licenses in use)
ccm_root phys-agsdev /dev/pts/67 u414014 (v1.0) (Phys-agsdev/19353 2477), start Mon 1/19 13:16
ccm_root phys-agsdev /dev/pts/19 z311203 (v1.0) (Phys-agsdev/19353 1449), start Mon 1/19 13:45
ccm_root phys-agsdev /dev/pts/104 u006134 (v1.0) (Phys-agsdev/19353 2017), start Mon 1/19 15:31

I'm now going to try and insert headers for username and process ID etc.

Thanks again. :b: