GagA// 0n D nEt

It is currently Sun May 20, 2018 3:23 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Script: Transfer file to multiple servers
PostPosted: Thu May 14, 2009 5:25 am 
Offline

Joined: Wed Jul 18, 2007 1:14 am
Posts: 181
The following is a small script which can be used to deploy/transfer a file on multiple servers at one time.

Please note that the following script will work without any manual intervention where the servers are having their keys exchanged without requiring password to login.

Code:
#!/bin/bash
#
# File Deployment on Multiple Servers
# Author: Gagan Brahmi
# Version: 1.0
#
# This script is basically designed to transfer file to multiple servers.
# The script will work ideally/automatically between the servers which are having their keys exchanged for the proper user.
# This script is however designed to deploy single file at a time, but can very well be modified for multiple files.
#
# Changes
# 1.0 - Original Release
#

if [ -z "$1" ]      # Exit if no argument given.
then
   echo "Usage: `basename $0` file.extension"
   echo "Please provide a file name to be transferred"
   exit 1
fi

for i in `cat ~/hosts`   # ~/hosts file should include the hostnames/IP addresses for the servers where the file is to be transferred.
do
scp $1 [email protected]$i:/var/www/html/
done
exit 0


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group