2

I am working on Solaris and working on a script that turns on any disabled service . Here is the output file:

disabled        7:22:05 svc:/network/bla-bla:default
online         Jun_14   svc:/network/blu-blu:default

I would like my code to parse this and turn the disabled one on using nawk itself

Here is what I have tried by it doesn't work for some reason:

cat output | nawk '/disabled/ {system(svcadm enable $3)}'

here is the output it gives:

**sh: line 1: svc:/network/bla-bla:default: not found** 

The output i need on cat output |grep bl* is :

online        7:22:05 svc:/network/bla-bla:default
online         Jun_14   svc:/network/blu-blu:default

Can anyone explain to me why this happens and how to make this nawk work. All I want is

svcadm enable svc:/network/bla-bla:default

to be executed.

tomkaith13
  • 1,717
  • 4
  • 27
  • 39

1 Answers1

1

Because it's treating svcadm as a variable name, which has no value. Try

 nawk '{system("svcadm enable " $3)}'

(Sorry, I meant that as the nawk program -- corrected now.)

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
  • It doesn't work yet.. it now throws the error "sh: line 1: 0: not found" – tomkaith13 Jun 22 '11 at 20:51
  • I got it !!! the plus was the problem since its not a string concatenator in shell scripts ....Thank you for this. If u can correct the answer I will go ahead n mark it right – tomkaith13 Jun 22 '11 at 20:58