For loop

Posted on 2011-10-07
Last Modified: 2013-11-17
I have one server (master server) that has ssh keys to all the rest of the servers in the environment. I need help to write a for loop to scp software, script, and etc from my master server to the rest of the servers using a server list I have compiled (all.servers file).
Question by:AIX25
    LVL 9

    Accepted Solution

    You looking for something like...

    for host in `cat all.servers`
       scp file $user@$host:/someplace/

    Open in new window


    Author Comment

    I just saw your reply. I'm done here and will be back on Monday to test it out and see if i have any problems! Thanks for you quick response.
    LVL 68

    Assisted Solution

    Why a "for" loop, (and why "cat")?

    xargs -I{} scp source_spec user@{}:target_spec/ < all.servers


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap ( Version 1.2 2.      Jpcap( Version 0.6 Prerequisite: 1.      GCC …
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    This tutorial goes over how to archive and restore FreeBSD jails that are managed by ezjail.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now