Red Hat This forum is for the discussion of Red Hat Linux. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-16-2011, 06:34 AM
|
#1
|
LQ Newbie
Registered: Jun 2011
Posts: 28
Rep:
|
to scp to multiple Linux systems by using for loop script
Hi,
I want to scp certain file(s)/folder to multiple Linux systems at a single point of time by using "for loop script". Please help me.
Thanks & Regards,
Vijay
|
|
|
07-16-2011, 02:14 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,192
|
Quote:
Originally Posted by dezavu
Hi,
I want to scp certain file(s)/folder to multiple Linux systems at a single point of time by using "for loop script". Please help me.
|
We will be glad to HELP you...post what you've written and tried, and where you're getting stuck, and we can assist. But we're not going to write your scripts for you.
Also, you need to provide details, like how you're going to determine what file(s)/folder(s) you want to copy, where the list of multiple systems is going to come from, and what kind of authentication you're going to use.
|
|
|
07-18-2011, 01:22 PM
|
#3
|
Member
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683
Rep:
|
First off you ought to have your ssh keys set up on all systems or it's going to prompt you every time it goes to another server.
Basic For loop syntax:
Code:
for i in server1 server2 server3; do (the thing you want done $i represents your list) ; done
so example to pull a hosts file from every server and save it as the server#_hostsfile
Code:
for i in server1 server2 server3; do scp $i:/etc/hosts $i_hostsfile ; done
It's not really a single point in time though if your files are large. The for loop moves sequentially so if each takes 10 seconds to complete then system1 = 0 seconds, system2 = +10 seconds, System3 = +20 seconds, etc. If your list is 100 servers long you would have a 1000 seconds difference between the first and last.
|
|
|
07-27-2011, 02:48 AM
|
#4
|
LQ Newbie
Registered: Jun 2011
Posts: 28
Original Poster
Rep:
|
Thanks. Now I wants to execute some scripts/commands from another system to the target system(s), by using "for loop". How do I do?
Thanks & Regards,
Vijay
|
|
0 members found this post helpful.
|
07-27-2011, 08:51 AM
|
#5
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,192
|
Quote:
Originally Posted by dezavu
Thanks. Now I wants to execute some scripts/commands from another system to the target system(s), by using "for loop". How do I do?
|
You were told how to above. You were also asked to post what you've written so far, and directed to look up one of the THOUSANDS of VERY easy to find bash scripting tutorials.
Did you do any of those?
|
|
|
07-27-2011, 08:57 AM
|
#6
|
Member
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375
Rep:
|
Stealing a previous example to show how to execute a script on a remote system via ssh, first create the script on the local system you'll be running it from, then:
Code:
for i in server1 server2 server3; do ssh user@$i 'bash -s' < /path/to/script.sh; done
|
|
1 members found this post helpful.
|
08-02-2011, 03:11 PM
|
#7
|
LQ Newbie
Registered: Jun 2011
Posts: 28
Original Poster
Rep:
|
Thank You!!!!!!
|
|
0 members found this post helpful.
|
05-22-2012, 11:36 PM
|
#8
|
LQ Newbie
Registered: Jun 2011
Posts: 28
Original Poster
Rep:
|
For Loop for creating multiple file systems in one shot in sequence
Thank You!
Now I want to create for loop for creating multiple file systems in one shot in sequence! Is it possible & if yes then how?
It will be great help for me!
Thanks & Regards,
Vijay
|
|
|
05-22-2012, 11:43 PM
|
#9
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,398
|
This thread was a year old and that's a new qn; please start a new thread with a good title
|
|
|
All times are GMT -5. The time now is 05:12 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|