Loop through the accounts and servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loop through the accounts and servers
# 1  
Old 01-12-2009
Loop through the accounts and servers

Hi everyone, I am trying to use loop (for loop but can be any loop) which will read from the file (text file) which will have 2 column one for account and another for server which kind of look like this

account1 server1
account2 server2
account3 server1
account4 server1
5 server3
6 server2
7 server2
8 server3
9 server4
10 server4

now here I have to run couple of ksh scripts which i wrote (example tar, stop, start). I have to read from the text file and using those accounts and respective servers I have to login and run those scripts one at a time for all the accounts and respective servers.

If there are 10 accounts they may be in 3 or 4 differnt servers and may not be in sequence as i have writeen down above but thats not a big issue I can put that in some sequence if needed. Write now I am doing it using multiple text files. If I have accounts in 5 servers then I put five text files where I put accounts name and loop through them using resepctive server but I need some way to do that using one text file as I have written before.

I hope I made it clear this time if not i will try to elaborate more later on

I will really appreciate any help
thanks alot
# 2  
Old 01-12-2009

Code:
while read account server
do
   echo "account=$account"
   echo "server=$server"
done < FILENAME

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

How to use AD accounts in AIX?

Hello, I've searched on-line (IBM and other sites). But did not get a clear answer/steps. My Requirement: use existing active directory accounts to login to AIX servers Can you please give me some information on how to achieve this. How this Active Directory and AIX server integration... (8 Replies)
Discussion started by: aaron8667
8 Replies

2. Shell Programming and Scripting

Script To Delete User Accounts On Multiple Servers

Hello All, The servers in question are AIX/Unix servers. I was hoping to find a scripting solution where I could use one server as a jump server and run a script that would check each server for a user account (the source file for the user accounts would be a text file or csv file) , and delete... (4 Replies)
Discussion started by: k45bryant
4 Replies

3. Shell Programming and Scripting

Ssh to an array of servers in a for loop

There are 4 remote hosts that I have stored in an array. A ssh trust has been created from the local host to each of the remote hosts. I am trying to ssh to each of the servers in a for loop as shown below. declare -a host host}]="server1" host}]="server2" host}]="server3" ... (9 Replies)
Discussion started by: Sree10
9 Replies

4. Red Hat

For loop to add user accounts

Hi i need to add 100 users on a redhat linux box . Can you guys help me . useradd -u 123456 -g 400000 -G 4545 -c " abcdef " -m -d /home/abcd -s /bin/bash abcd (1 Reply)
Discussion started by: karthik9358
1 Replies

5. Shell Programming and Scripting

Problem sshing to multiple servers while in a loop

I have the following block from a script (it's not the entire script, but I'm confident it's all that is pertinent) echo "$SESSIONS"|while read ID;do ASSETID=$(echo "$ERRORS"|grep -i "$ID"|grep FX_Media_Session_Playlist::init_playlist|grep -i asset_id=|awk '{print $11}') BLADE=$(echo... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

6. Post Here to Contact Site Administrators and Moderators

Combine Accounts

I have two different accounts under two names. That is my fault and I own that issue. I would like to combine the two account or just remove one of them. How do I go about doing that on this site. (1 Reply)
Discussion started by: crobinson
1 Replies

7. Shell Programming and Scripting

User Accounts

I have found a script to create user accounts. But there are a few lines i dont understand. Can someone help me with this? Here's the code: ###################################### while ; do ACCT=${USER_ACCT}${START} START=`expr $START + 1` START=`echo ${START} | awk... (3 Replies)
Discussion started by: Sensor
3 Replies

8. UNIX for Dummies Questions & Answers

Mail accounts

Hi there I am a newbie. want to learn followings: 1. How can i create an mail only account.? 2. Where is the file containing mail accounts?What is the path? 3. Can i create mail accounts from PHP? Thanx (3 Replies)
Discussion started by: vbs
3 Replies
Login or Register to Ask a Question