Getting one script to run on multiple boxes


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Getting one script to run on multiple boxes
# 1  
Old 03-15-2006
Getting one script to run on multiple boxes

I have a script that generates an output file after pulling data from a local DB on one of my boxes. There are other nearly-identical boxes on the network, each with their own local DB, and I'd like to run the script there too. Copying the script to each box and then running them individually works, but it is a bit tedious. Wondering how to automate?

Ideally, I'd like to execute *one* script on *one* box to collect the info from all of the boxes. My first idea was to have the script remotely connect to each of the other boxes' DBs, but that's not going so well... The other choices I am considering are:

* One script that executes it code on a series of remote boxes. How can that be done?

* Copy the script to each box, and use a "kick-off" script that tells each of the remote boxes to execute a local script. How can that be done?

I am looking into rexec and rshell, but I currently know nothing about these commands. I should probably mention that I can rsh to any of the remote boxes without challenge (the same user exists on all boxes).

Finally, any advice on how to transfer remote output files back to the box that ran the "kick-off" script? Look into rcopy or ftp?

Thanks for your guidance!
# 2  
Old 03-15-2006
try this ... (fix path to ksh as required) ... enjoy!
Code:
#! /bin/ksh

for host in server1 server2 server3
do
    rcp -p /dir/script $host:/dir/script
    rsh $host "/dir/script"
    rcp -p $host:/dir/script/outfile /outdir/outfile.$host
done

exit 0

signing off ....

Last edited by Just Ice; 03-15-2006 at 09:13 AM.. Reason: add file transfer code ...
# 3  
Old 03-15-2006
My solution to this was to write a shell script trigger file monitor.

Every minute via cron the script checks for a trigger file containing the command or script to run, if the file is there, it runs the script, deletes the file and e-mails the results to me.

To control it, I wrote a small shell menu that allows you to send the script to a list of hosts specified via SFTP for security purposes. This is just a standard ksh menu script with an expect function tied into it for the SFTP authentication portion.
# 4  
Old 03-15-2006
Just_Ice:

I like the idea and the simplicity! Just wondering, is it (rsh $host "script") or (rsh $host -e "script")? A pal suggested using "-e", but I can't find that switch in the man pages.

NOW... Let's say that I'd prefer to not hard-code the server names into the "for" loop, but pull a list of server names from a text file. Any suggestions there?

Thanks!
# 5  
Old 03-16-2006
Can't help on the -e flag. Aix 5.x doesn't have one.

On the other question, you could create a list of hosts in a file and wrap a file read loop round Just_Ice's script:

Code:
while read host b
do
  rcp -p /dir/script $host:/dir/script
  rsh $host /dir/script
  rcp -p $host:/dir/script/outfile /outdir/outfile.$host
done <  listofhostsfile

As the hosts you want to run the script on will be in your .rhosts, you could use this instead of setting up another list (on the other hand, if there are (or will be) hosts you don't want to run the scripts on then you would need to add a file of exclusions - which probably makes this too complicated and you may as well just use a specific file!)

cheers
# 6  
Old 03-16-2006
Have you consider using NFS to share the file across the servers?
# 7  
Old 03-16-2006
Quote:
Originally Posted by thestevew

Code:
while read host b
do
  rcp -p /dir/script $host:/dir/script
  rsh $host /dir/script
  rcp -p $host:/dir/script/outfile /outdir/outfile.$host
done <  listofhostsfile

Thanks, thestevew! What's the "b" for at the end of the 'while' line? Typo?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Run script on multiple files

Hi Guys, I've been having a look around to try and understand how i can do the below however havent come across anything that will work. Basically I have a parser script that I need to run across all files in a certain directory, I can do this one my by one on comand line however I... (1 Reply)
Discussion started by: mutley2202
1 Replies

2. Shell Programming and Scripting

Run a script on multiple servers

I need to run a script on a bunch of remote servers. how can this be done without ssh into each individual server and run it its under /sbin/script.sh on each server (1 Reply)
Discussion started by: tdubb123
1 Replies

3. Shell Programming and Scripting

Need a script to scp a file to multiple boxes

Hello All, I am new to scripting and I am trying to write a script which can scp a file from one box to multiple boxes. I am thinking to do like this. 1) create a file with list of all server names 2)write a script which will pick up each server line by line from server list and copy it to... (1 Reply)
Discussion started by: sintilash
1 Replies

4. Shell Programming and Scripting

Shell script to login into multiple linux boxes

I have requirement to login into a multiple linux boxes by running the shell script in a single linux box and to find the count of files in a specific folder in each box and log them in a log file in the box where i m runnning the script. Box names will be stored in a text file host.txt. Please... (2 Replies)
Discussion started by: Mani2512
2 Replies

5. Shell Programming and Scripting

Script to run php script on multiple website domains

Good Day, I have multiple websites on a domain. I am looking for a loop structure that can run each site script. egdomain1/test.php domainx/test.php so on, currently I copy and paste a list of commands but that skips certain commands. Some help would be greatly appreciated. Sergio (3 Replies)
Discussion started by: SergioP
3 Replies

6. Shell Programming and Scripting

Automated ssh to multiple boxes

I have a script that will ssh to several different servers, perform a command, display the output, and exit. It works well, but I have to enter my password for each server. That gets a little cumbersome when you have a couple dozen servers. Anyone out there know how to automate this so that I only... (2 Replies)
Discussion started by: fedexer
2 Replies

7. UNIX for Dummies Questions & Answers

Virtualbox OSE on multiple boxes

I have Virtualbox OSE installed on my laptop and soon on my lap top. My question is if I were to make a virtual os on an external hard drive on my laptop, can i make a settings to use the same vdi on my desktop and have it show the same screen, not at the same time. sorry, its late here and I... (0 Replies)
Discussion started by: Texasone
0 Replies

8. Shell Programming and Scripting

I need a Script to rsh multiple hp boxes and shutdown

Hello I'm serving on a ship that has frequent power issues. Currently if we loose power we need to rush around to multiple UNIX machines and login to Sysadmin and power down each machine before we loose our ups. If sysadmin is asleep or not in the space we have some real problems. I would like to... (2 Replies)
Discussion started by: blackfam972
2 Replies

9. Programming

text boxes, radio buttons , check boxes in c++ on unix

Hi ! Please tell me how to get radio buttons, text boxes , check boxes , option buttons , pull down menus in C++ on Unix. I think it would be done using curses.h ..but that's all i know. TIA, Devyani. (3 Replies)
Discussion started by: devy8
3 Replies
Login or Register to Ask a Question