Copying / SCPing the files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying / SCPing the files
# 1  
Old 12-08-2009
Copying / SCPing the files

Hi All,

Could you please help me out how can i copy the file from one system to another using scp.

For example - i have systems A,B,C in one location
And i have systems D,E,F in second location.

Now, I wan to copy the files from Systems A->D, B->E, C->F using scp in loop or any condition statements...

Please help me out!!!

-Sandeep

Last edited by sdosanjh; 12-08-2009 at 02:19 AM..
# 2  
Old 12-08-2009
Hi

the syntax for scp is

Code:
scp <file to copied> <location to be copied>

either of the two arguments can be on a remote system
for a remote system the syntax is for the form
<user>@<pwd>:<location of the file>

if you need a series of interconnected scp transfers, i would suggest that you use password less login between the machines.

scp can also be performed as a ant tasks, if u require it.

cheers
# 3  
Old 12-08-2009
thanks for the reply. I got the syntax,. but i want the loop to get the files transferred from a->d and other simultaneous systems.

Because if there are 20 systems on each location i need 20 scp's but if anybody tell me how we can do it through loop or condition statements?

---------- Post updated at 10:18 PM ---------- Previous update was at 10:17 PM ----------

i have password less login between the systems.
# 4  
Old 12-08-2009
hi sandeep

assuming you have predetermined list of servers , say A,B,C,D you may like to do

Code:
servers="A B C D"
for i in $servers
do
 for temServer in $servers 
  do
     if [ $i == $tempServer ] ; then
       continue
      else
        // your scp command goes here 
     fi
 done
done

this will giv you all the possible combinations for the servers.

hope it was of some use
# 5  
Old 12-08-2009
Maybe it could be appropriate to use rsync.
# 6  
Old 12-08-2009
Akshay,

It will work, but with all the permutation and combinations. the number of systems i am willing to scp the file is more, probably 30 in one location. so in total it will become 60 systems. so the loop will be more in the cycle than on actual scp statement.

To refigure.. my requirement is

System1="A B C D"
System2="E F G H"

Now SCP should be
first, from A -> E
Then, From B-> F
then, from C -> G .... so on...

Any help in this regard will be much appreciated ...

Last edited by sdosanjh; 12-10-2009 at 03:31 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files

I'm trying to do this exact same thing, so far I have created this to move files i've named my script CP.sh #!/bin/bash cd /root/my-documents/NewDir/ for f in *.doc do cp -v $f root/my-documents/NewDir $f{%.doc} done When i go to run this in the console i type, bin/sh/ CP.sh but it... (7 Replies)
Discussion started by: MKTM_93_SIMP
7 Replies

2. Shell Programming and Scripting

Copying files

All, I need to grab and rename common files from several unique directory structures. For example, the directory structures looks like: /unique_dir/common/common/common/person_name_dir/common_file.txt There are over 90,000 of these text files that I'd like to put in a single directory as... (5 Replies)
Discussion started by: hburnswell
5 Replies

3. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

4. Shell Programming and Scripting

Copying Files

Hi All, I'm trying to list some files from my log directory and files are like this log.20110302_20.gz log.20110302_21.gz log.20110302_22.gz log.20110302_23.gz log.20110303_00.gz log.20110303_01.gz log.20110303_02.gz ............ log.20110311_22.gz log.20110311_23.gz... (2 Replies)
Discussion started by: thelakbe
2 Replies

5. UNIX for Dummies Questions & Answers

scping files while logged in via ssh

Hi, I was wondering how I would copy a file from a server to my computer while being logged into the server via ssh. I know I can get the file by using scp or sftp while logged out, but is there a way to do this while in an ssh connection? (3 Replies)
Discussion started by: Colecf
3 Replies

6. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

7. Solaris

Copying Files

Hi, I understand that to copy files across server, the feasible way will be using scp command. Am I right? What if the two servers are not connected to a network? If by using a cross cable to link up both the server, what will be the best (fastest) way to copy files across? scp as well? ... (3 Replies)
Discussion started by: user50210
3 Replies

8. Shell Programming and Scripting

copying files

hi I want to copy all files from the current directory and move to .archive file. Moreover,I want to add .bak to each file name, that will be copied. How can I do that? (4 Replies)
Discussion started by: tjay83
4 Replies

9. Solaris

Copying Files and

I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory. One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
Discussion started by: patilmukundraj
1 Replies

10. UNIX for Dummies Questions & Answers

Copying files

I like to know the command structure of copying files/directories from a unix box using telnet session to a windows box. (4 Replies)
Discussion started by: alpheusm
4 Replies
Login or Register to Ask a Question