LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 07-16-2011, 06:34 AM   #1
dezavu
LQ Newbie
 
Registered: Jun 2011
Posts: 28

Rep: Reputation: Disabled
Question 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
 
Old 07-16-2011, 02:14 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,192

Rep: Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068
Quote:
Originally Posted by dezavu View Post
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.
 
Old 07-18-2011, 01:22 PM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
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.
 
Old 07-27-2011, 02:48 AM   #4
dezavu
LQ Newbie
 
Registered: Jun 2011
Posts: 28

Original Poster
Rep: Reputation: Disabled
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.
Old 07-27-2011, 08:51 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,192

Rep: Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068Reputation: 8068
Quote:
Originally Posted by dezavu View Post
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?
 
Old 07-27-2011, 08:57 AM   #6
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
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.
Old 08-02-2011, 03:11 PM   #7
dezavu
LQ Newbie
 
Registered: Jun 2011
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thank You!!!!!!
 
0 members found this post helpful.
Old 05-22-2012, 11:36 PM   #8
dezavu
LQ Newbie
 
Registered: Jun 2011
Posts: 28

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-22-2012, 11:43 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,398

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
This thread was a year old and that's a new qn; please start a new thread with a good title
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple scp/ssh in one bash script Lovelyhard Programming 13 07-31-2012 09:37 AM
[SOLVED] Help making specific script loop over multiple files in directory novloski Linux - Newbie 3 05-11-2011 05:13 AM
[SOLVED] Bash backup script with scp, multiple processes mky Programming 8 09-29-2010 06:28 PM
Checking multiple systems on network with command "top" using a Linux Script Echo Kilo Programming 16 06-15-2008 06:33 PM
shell script - while loop with multiple conditions ronsha Programming 13 12-10-2005 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 05:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration