tomkaith13
tomkaith13

Reputation: 1727

Regarding nawk and system command

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.

Upvotes: 2

Views: 678

Answers (1)

Charlie Martin
Charlie Martin

Reputation: 112404

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.)

Upvotes: 1

Related Questions