Sara_84
November 21, 2013, 4:37am
1
Hello
can you please help me with below script which is meant to delete clients from multiple netbackup policies
I want to run a command insdie awk statement
apparelnlty this script is not working for me
for i in $( cat clients_list)
do
bppllist -byclient $i | awk '/^CLASS/{system("bpplclients $2 -delete $i")}'
done
cat clients_list
client1
client2
client3
client4
...
...
Many Thanks
Sara
Scott
November 21, 2013, 4:49am
2
Try:
... | awk -v i=$i '/^CLASS/{system("bpplclients " $2 " -delete " i)}'
You should show some output of bppllist -byclient $i, and what bpplclients expects as input, otherwise it's just a guess, really.
Sara_84
November 21, 2013, 5:02am
3
this command will list all policies that have client1
bppllist -byclient client1 | awk '/^CLASS/{print $2}'
output
policy1
policy2
policy3
below command delete client from previous policies
bpplclients policy1 -delete client1
bpplclients policy2 -delete client1
bpplclients policy3 -delete client1
Scott
November 21, 2013, 5:07am
4
Then it should work. Does it not?
Sara_84
November 21, 2013, 5:16am
5
no it is not working unfortunately L
Could this help ?
for i in $(cat clients_list)
do
bppllist -byclient client1 | awk '/^CLASS/{print $2}' | while read policy
do
bpplclients $policy -delete $i
done
done
1 Like
Scott
November 21, 2013, 5:28am
7
Just saying it isn't working isn't exactly helpful.
If the output of bppllist -byclient client1, 2, 3, 4, etc.
is:
policy1
policy2
policy3
policy4
...
Then the following command (to simulate the next step) gives the shown output:
for i in $( cat clients_list)
do
echo CLASS policyN $i | awk -v i=$i '/^CLASS/{system("echo bpplclients " $2 " -delete " i)}'
done
bpplclients policyN -delete client1
bpplclients policyN -delete client2
bpplclients policyN -delete client3
bpplclients policyN -delete client4
So:
for i in $( cat clients_list)
do
bppllist -byclient $i | awk -v i=$i '/^CLASS/{system("bpplclients " $2 " -delete " i)}'
done
should execute:
bpplclients policy1 -delete client1
bpplclients policy2 -delete client2
bpplclients policy3 -delete client3
bpplclients policy4 -delete client4
1 Like