John Sheehy
asked on
SCP a file to multiple machines using a script
So I have one file that I need to scp to multiple machines. In the beginning this was easy as we only had 3 machines, now we have over 40 and it gets old real fast typing in the same thing over and over and the host names change all the time. Once the file is SCP a seperate command runs to execute a script on the host machine. That part works great. It SSH ins executes the script and moves onto the next machine. But I can't seem to get the file to scp using the same methodology as I did with SSH. What am I doing wrong?
So I did try this but it doesn't seem to work:
sudo=/usr/bin/sudo
ssh=/usr/bin/ssh
scp=/usr/bin/scp
USERNAME = <username>
SCRIPT="<script>"
HOSTS="HOST1 HOST2 HOST3......HOTS40"
VPATH="/h/USERS/local/<use rname>"
for HOSTNAME in ${HOSTS}; do
scp *.tar ${USERNAME} ${HOSTNAME} ${VPATH}
done
for HOSTNAME in ${HOSTS}; do
ssh -l ${USERNAME} ${HOSTNAME} "sudo ${script}"
done
Thank
John
So I did try this but it doesn't seem to work:
sudo=/usr/bin/sudo
ssh=/usr/bin/ssh
scp=/usr/bin/scp
USERNAME = <username>
SCRIPT="<script>"
HOSTS="HOST1 HOST2 HOST3......HOTS40"
VPATH="/h/USERS/local/<use
for HOSTNAME in ${HOSTS}; do
scp *.tar ${USERNAME} ${HOSTNAME} ${VPATH}
done
for HOSTNAME in ${HOSTS}; do
ssh -l ${USERNAME} ${HOSTNAME} "sudo ${script}"
done
Thank
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I made the changes and it worked out great. I am closing this question but I have three more I will be asking.
Thanks
John
Thanks
John
ASKER
Answer was correct and direct to the point. Very easy to understand.
ASKER
Thanks
John