to get the exact word from the file using script

Hi everybody,

I have one requirment,
i have to get the particular server name from a file.
EX:
File contents will be like below..

$cat test.txt
HostAssignments->new("server1",
[
"PS_SERVER",
"REG_SERVER",
"PS_ORACLE",
"OM_G10_AUD",
"OM_G10_CAD",
"OM_G10_CHF",

HostAssignments->new("server2",
[
"OM_EM_A",
"OM_EM_B",
"OM_EM_A2",
"OM_EM_B2",
"OM_G10_AUD",
"OM_G10_CAD",
"OM_G10_CHF",
"OM_G10_DKK"
$

So in this file, i have to find out the server name under whcih server we've the below three processes
PS_SERVER
PS_ORACLE
REG_SERVER

For example, i should get the 'server1' word from the above file, as under this server i've the PS_SERVER, PS_ORACLE and REG_SERVER processes.

Can anyone please help on this?

Please let me know for any doubts on my requirment..

Thanks in advance..
Raghu..

awk 'BEGIN{RS="";FS="\n"} /PS_SERVER/&&/PS_ORACLE/&&/REG_SERVER/ {split($1,a,"\"");print a[2]}' urfile

thank you vm for this code, it's working..

But as i dont know the awk functionality, it will be bit difficult to debug in future to me, if i face any issues. So can you please try in shel script or any command line..?

Regards,
Raghu..

Maybe something like this ?

$ 
$ cat -n test.txt
     1  HostAssignments->new("server1",
     2  [
     3  "PS_SERVER",
     4  "REG_SERVER",
     5  "PS_ORACLE",
     6  "OM_G10_AUD",
     7  "OM_G10_CAD",
     8  "OM_G10_CHF",
     9
    10  HostAssignments->new("server2",
    11  [
    12  "OM_EM_A",
    13  "OM_EM_B",
    14  "OM_EM_A2",
    15  "OM_EM_B2",
    16  "OM_G10_AUD",
    17  "OM_G10_CAD",
    18  "OM_G10_CHF",
    19  "OM_G10_DKK"
$ 
$ perl -lne '$x=$1 if /^HostAssignments.*?\("(.*?)"/; $i++ if /PS_SERVER|REG_SERVER|PS_ORACLE/; if ($i==3){print $x; $i=0}' test.txt
server1
$ 
$ 

tyler_durden