2) Shell Script to use rsync to copy the files to remote servers
#!/bin/sh
## Author: Pavan Bandaru
## Date: 9/28/2018
set -x
display_usage() {
echo "This script must be run with ...."
echo -e "\nUsage:\n$0 [hostfile.txt] \n"
}
if [ $# -eq 0 ]; then
display_usage
exit 1
fi
hostfile=$1
for host in `cat<$hostfile`
do
hostname=$(echo $host|awk -F"," '{print $1}')
echo "------------------------------------------------"
echo "connecting to $hostname"
rsync -r localdir ${hostname}:/home/pavan/
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo Login Failed
fi
done
hostfile.txthost1host2host3host4
No comments:
Post a Comment