Visit Our UNIX and Linux User Community


Need help to make connection to various hosts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help to make connection to various hosts
# 1  
Old 09-03-2009
Need help to make connection to various hosts

Guys

If someone could help me? Basically I want to connect from my central server and run the script to remote servers (in our environment we do not need a username/password to connect); like below

ssh <server_name_1> /ora/rman/scripts/bk2.sh 2>/dev/null >> /tmp/an.log
ssh <server_name_2> /ora/rman/scripts/bk2.sh 2>/dev/null >> /tmp/an.log
..
..
ssh <server_name_n> /ora/rman/scripts/bk2.sh 2>/dev/null >> /tmp/an.log

I have all these servers name in one file.....so basically I need to loop through all these servers/hosts and run above command

Also while making connection to server I also want to scp my script (i.e. bk2.sh) to all these servers

Could anyone please help?
# 2  
Old 09-03-2009
man rdist...
# 3  
Old 09-03-2009
Code:
#!/bin/sh

while read host
do
   scp bk2.sh $host:/ora/rman/scripts/bk2.sh
   ssh $host /ora/rman/scripts/bk2.sh 2>/dev/null >> tmp/an.log
done < hostlist

# 4  
Old 09-04-2009
Thanks; but this only works for the first server in the list...any suggestions to make it workable for all the servers in the file? And if I remove '/' from /tmp/an.log then scp works for all servers but ssh only works for the first server in the list



while read host
do
scp bk2.sh $host:/ora/rman/scripts/bk2.sh 2>/dev/null
ssh $host /ora/rman/scripts/bk2.sh 2>/dev/null >> /tmp/an.log
done < /export/home/oracle/server.lst

Previous Thread | Next Thread
Test Your Knowledge in Computers #242
Difficulty: Easy
In September 1984 work was completed on restructuring the ARPANET giving U.S. military sites their own Military Network (MILNET) for unclassified defense department communications.
True or False?

10 More Discussions You Might Find Interesting

1. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

2. Shell Programming and Scripting

Ssh to validate multiple remote hosts connection validation.

Dear Folks, I am trying to read a config file contains ip and port numbers. i want to read each line of the config file and check ssh connection is happening or not. Kindly guide. Config file: abc@1.2.342 22 abc@1.2.343 22 abc@1.2.344 22 abc@1.2.345 22... (9 Replies)
Discussion started by: sadique.manzar
9 Replies

3. UNIX for Dummies Questions & Answers

Test Connection to hosts

i have about 3500 hosts/devices which i monitor. i monitor them from one host. we'll call this one host HOSTA. HOSTA has connectivity to all 3500 hosts/devices. now, i have to create a backup for HOSTA. and the back up is in another state. how do i get a list of all open ports on HOSTA so... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. AIX

aix tcp wrappers hosts.allow hosts.deny?

hi all just installed the netsec.options.tcpwrapper from expansion pack, which used to be a rpm, for my aix 6.1 test box. it is so unpredictable. i set up the hosts.deny as suggested for all and allow the sshd for specific ip addresses/hostnames. the tcpdchk says the hosts allowed and... (0 Replies)
Discussion started by: wf201626
0 Replies

5. Solaris

Solaris 10 ftp connection problem (connection refused, connection timed out)

Hi everyone, I am hoping anyone of you could help me in this weird problem we have in 1 of our Solaris 10 servers. Lately, we have been having some ftp problems in this server. Though it can ping any server within the network, it seems that it can only ftp to a select few. For most servers, the... (4 Replies)
Discussion started by: labdakos
4 Replies

6. AIX

How many connection can a user make?

Where do i check how many connection a same user name can make to a UNIX/AIX system. for examples root login from local physical machine root login from LAN via telnet at the same time root login from internet via telnet also at the same time.. where do i check and how do i change this ? ... (3 Replies)
Discussion started by: dplinux
3 Replies

7. Shell Programming and Scripting

Want to make a script that checks connection protocol

Hello all, I currently connect to several servers multiple times a day. Most of the time I connect via SSH through the terminal emulator poderosa (my personal favorite), but sometimes I connect via telnet through xstart because I need it to export a GUI. What I want to do is add something to... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

8. Shell Programming and Scripting

Make sure connection

We have two servers , one is mount to another server , I am worry if the server is unstable , the connection ( mount ) will be broken , or when the server is rebooted , the connection will also be broken , can advise how can I make sure the mount is establish , can advise if I want to do the below... (1 Reply)
Discussion started by: ust
1 Replies

9. UNIX for Dummies Questions & Answers

Hosts.allow and hosts.deny

Hello everyone, This is my first posts and I did search for a questions but did not find a question that answered my question unless of course I overlooked it. I'm running Solaris 8. I use ssh for the users but I have a user called "chatterbox" that uses telnet but I need for chatterbox to... (1 Reply)
Discussion started by: huddlestonsnk
1 Replies

10. UNIX for Dummies Questions & Answers

hosts.allow & hosts.deny

Hi! Im trying to use host.allow & host.deny to resrtic access to my sun machine, but it doesnt seem to work... I want to allow full access from certain IPīs (ssh,http,ftp,etc...) but deny all kind of conections from outsideworld, the way that im doing that is: hosts.allow ALL:127.0.0.1... (2 Replies)
Discussion started by: Sorrento
2 Replies

Featured Tech Videos