Script to remove clients


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to remove clients
# 1  
Old 03-03-2012
Script to remove clients

I have a list of clients

Code:
 
$ cat clientlist
 
client1
client2
client3
client4

I need a script to read these clients from a file and list the contanining policies for each client ( one client may belong to more than one policy),

then I'd like to remove the client from all policies they belong to


this the first commamd to list policies for a client

Code:
 
bppllist -byclient $CLIENT | grep "CLASS " |  awk '{print $2}' |

output
Code:
 
 
policy1
policy2

the second command to removed the client from the policy ( one policy per command)

Code:
 
bpplclients $POLICY -delete $CLIENT

I will really appreciate your help

Thanks. Sara
# 2  
Old 03-03-2012
Hello ,
You want to do something like that . huh?
Code:
for CLIENT in $(cat clientlist)
do
     for POLICY in $(bppllist -byclient $CLIENT | grep "CLASS " |  awk '{print $2}')
     do
          bpplclients $POLICY -delete $CLIENT
     done
done

This User Gave Thanks to codemaniac For This Post:
# 3  
Old 03-03-2012
Quote:
Originally Posted by codemaniac
Hello ,
You want to do something like that . huh?
Code:
for CLIENT in $(cat clientlist)
do
     for POLICY in $(bppllist -byclient $CLIENT | grep "CLASS " |  awk '{print $2}')
     do
          bpplclients $POLICY -delete $CLIENT
     done
done

If the list of clients is long, or the client 'name' contains blanks, this would be a better way to read through the list. Also if the output of bpplclients is long the same applies. The grep isn't needed as awk can perform the search so the I/O is reduced.

Code:
#!/usr/bin/env bash
while read CLIENT
do
    bppllist -byclient "$CLIENT" | awk '/CLASS/ { print $2; }' | while read POLICY
    do
        bpplclients "$POLICY" -delete "$CLIENT"
    done
done <clientlist



Also note that POLICY and CLIENT are quoted when expanded to allow either to contain blanks.
This User Gave Thanks to agama For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Stopping Windows 10 Clients?

As I know you are all aware Windows 10 poses some serious security concerns. My question is three fold. 1. Is there a way to stop Windows 10 clients from accessing a web server? 2. What would be the MS counter punch to that? ie: how would they circumvent. (mask browser credentials?) 3. Is... (4 Replies)
Discussion started by: ScottyPC
4 Replies

2. Shell Programming and Scripting

Script to shutdown XP clients

My staff seem to have a habit of leaving thier PCs on over night so I need to write a short script to shutdown any XP clients logged into the local samba domain that I can run as a cron job at a set time. I can list the connected clients and their IP addresses with: $ smbstatus -b Samba... (6 Replies)
Discussion started by: barrydocks
6 Replies

3. Programming

Clients - Server ( UDP )

Hello, I have a question: I want to create a n client to one server connection. This is the client-server algorithm. Enybody help to make the changes? (0 Replies)
Discussion started by: MaHmur
0 Replies

4. UNIX for Dummies Questions & Answers

who am i showing clients hostname not ip?

i have two solaris 7 machines, host1 and host2 - host2 was "created" from host1 by using ufsdump/ufsrestore. on host1 > who am i user1 pts/175 Aug 8 11:22 (192.23.128.12) on host2 > who am i user1 pts/4 Aug 8 11:19 (coscwm5643_w764.xxx.mmmm.com) what... (2 Replies)
Discussion started by: rbaskett
2 Replies

5. Programming

forking for multiple clients

hello everyone, i am making a tcp chat server using c in linux. i have used socket programming to connect the server and the client. can anyone please let me know how i can use forking for multiple clients?? thank you (1 Reply)
Discussion started by: sweetbella
1 Replies

6. UNIX for Advanced & Expert Users

is this enough for a webserver of 200 clients

Hi all, This is my server configuration. Hard Disk - 500 GB RAM - 3GB Processor - intel core 2 quad ( 4 numbers). each one of four cores. We have an application hosted thorough tomcat and accessed via apache through mod_jk connector. There would be around 200 clients... (1 Reply)
Discussion started by: anishkumarv
1 Replies

7. UNIX for Advanced & Expert Users

Benchmarking a new Solaris, with four different clients

Good morning, for the impatient: I have a new backup-server and need to monitor, what the machine can do, what's the best way of finding that out? I will tell the story right from the beginning, so you have a clue about what's going on: I have a setup of three machines: A new... (6 Replies)
Discussion started by: PatrickBaer
6 Replies

8. UNIX for Advanced & Expert Users

Tracking NTP Clients

I need to find out the NTP Clients which are syncing with my NTP Server in a Unix(Linux/Solaris) Machine. For eg. How many Stratum 2 Servers sync the time with my Stratum1 Server. Is there any way to track it? edit by bakunin: moving the thread to where it belongs: the technical forums. (4 Replies)
Discussion started by: hottyspidy
4 Replies

9. IP Networking

Multihomed DNS Clients?

I'm not sure it that's the right term for what I'm asking about, but it's the best I could come up with. Here is my situation... I'm setting up a network using OpenVPN. The clients I'm setting up will need to be able to access their own DNS servers (to resolve internal names at their location)... (4 Replies)
Discussion started by: deckard
4 Replies

10. Linux

BOOTP on HP Thin clients

Please m new around here! Can anyone take me thru implementing bootp on my thin clients via my central server? Preciate ur assistance. Thanks folks! (2 Replies)
Discussion started by: chuk_uka
2 Replies
Login or Register to Ask a Question