Copying a list of files from one 'server' to another?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copying a list of files from one 'server' to another?
# 1  
Old 04-23-2007
Copying a list of files from one 'server' to another?

I have two servers. I would like to copy some files from one directory on server A into the same directory on server B.

Its not all the files in in the directory, just some of them.

Is there a way to make a file list in a txt file and then somehow copy all the files in that list in one go to the other server?

Thanks.
# 2  
Old 04-23-2007
files.txt contains a list of every file you want to copy.


Code:
for line in files.txt
do
    cp $line server:$line
done

You get the gist...

...oh - unless its scp or something and then you'd end up having to type in your password for each line Smilie
# 3  
Old 04-23-2007
Quote:
Originally Posted by Sepia
I have two servers. I would like to copy some files from one directory on server A into the same directory on server B.

Its not all the files in in the directory, just some of them.

Is there a way to make a file list in a txt file and then somehow copy all the files in that list in one go to the other server?

What shell are you using? If it's bash or ksh put the list of files in an array, e.g.:

Code:
filelist=( "file 1" "file 2" etc. )

scp "${filelist[@]}" remote.server:path

Or use the list directly on the command line:

Code:
scp "file 1" "file 2" etc. remote.server:path

# 4  
Old 09-10-2008
use symlinks

Quote:
Originally Posted by cfajohnson

What shell are you using? If it's bash or ksh put the list of files in an array, e.g.:

Code:
filelist=( "file 1" "file 2" etc. )

scp "${filelist[@]}" remote.server:path

Or use the list directly on the command line:

Code:
scp "file 1" "file 2" etc. remote.server:path

In these situations you run the risk of exhausting the maximum length of arguments to a process. I ran into this problem today when I needed to randomly divide two massive sets of files evenly between two servers. Create a new directory for each server and fill it with symlinks to the files you wish to copy to that server. If it's a lot of files, automate it by creating a script:

Code:
cat file_list | sed 's/^.*$/ln -s & /' > symlink_script.sh

Execute the script inside of your new directory. Then, just copy that directory over to the target server, and scp will follow the symlinks.
# 5  
Old 05-04-2009
File server from one server to another server

Can anyone give me complete discription of following statement as am new to Unix.

scp "file 1" "file 2" etc. remote.serverSmilieath

I want to transfer file e.g test.sh to C drive in 102.19.23.122 ,

I am tryig like
scp test.sh 102.19.23.122:C

but its not working ,
# 6  
Old 05-04-2009
Quote:
Originally Posted by KiranKumarKarre
Can anyone give me complete discription of following statement as am new to Unix.

scp "file 1" "file 2" etc. remote.serverSmilieath

I want to transfer file e.g test.sh to C drive in 102.19.23.122 ,

I am tryig like
scp test.sh 102.19.23.122:C

but its not working ,
For this copy, it will be easier for you to just do a ftp from the DOS command prompt

Code:
open DOS 
cd c:
ftp unixbox
user
paswword
cd /dir  [ directory where your tesh.sh is present]
get test.sh
bye

cheers,
Devaraj Takhellambam
# 7  
Old 05-05-2009
Make sure you're getting your syntax correct.

scp /file/location/of/test.sh 102.19.23.122@:/file/location/to/copy/to

And also - make sure you actually can reach 102.19.23.122 Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

List all files and copying to different location

Hello All, I want to copy all files from the list below to a path /qa0/repo/AS/CPY (lnx17:qa0:/qa0/repo/AS>) ls -lrt | grep 'Feb 14' -rw-rw-r-- 1 Ks1 qa0 39 Feb 14 20:11 HHH.dat -rw-rw-r-- 1 Ks1 qa0 32 Feb 14 20:11 HHH1.dat -rw-rw-r-- 1 Ks1 qa0 29 Feb 14 20:11... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Shell Programming and Scripting

Copying files to remote server

I am trying to copy code to remote server, doing something like this However it is copying one file and than the script exits i=0; j=0 while read fn; do dir=${fn%/*} # Gets directory path fnm=${fn##*/} # Gets filename excl. path rgx_nwk="s/${nwk}/${nwk}.sac/g" ... (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

Copying the files to Windows server from UNIX server

Hi Team, I had a requirement to write a shell script which automatically transfer the files from unix server to windows server. I can able to unix to unix using Scp command. I am not sure how to do unix to windows. I am very new on this concept. Could you please help me or guide in... (4 Replies)
Discussion started by: gvkumar25
4 Replies

4. UNIX for Dummies Questions & Answers

Copying files from one server to another

I need to copy huge set of data(files & floder) from one server to other. Can any one guide me.I have tried throught ftp mget but it is vain...floder are not moving...... Do suggest me any good method (12 Replies)
Discussion started by: kkalyan
12 Replies

5. Shell Programming and Scripting

Copying List of Files Under Different File Names ?!

Hi to all here , Excuse me for the lamer question but I need UNIX command for copying List of Files Under Different File Names ! for example I have this list: new_001.jpg new_002.jpg new_003.jpg ..... I want to copy all files that start with "new_" to the same directory but under... (7 Replies)
Discussion started by: boboweb_
7 Replies

6. UNIX for Dummies Questions & Answers

Copying files from different server

Is there any option to copy files from a different server other than using an SCP command??? thanks,:b: Arun manas (2 Replies)
Discussion started by: arunmanas
2 Replies

7. Shell Programming and Scripting

Copying files from one server to other.

Any one advice here- need to copy some files from one server to other server thru shell programming. (8 Replies)
Discussion started by: samkhu
8 Replies

8. Shell Programming and Scripting

copying a list of files from one machine to another with the same path

Hello All, I would like to download a list of files from a remote server to my local machine preserving the path i.e, create a similar directory tree. ex: files on the remote machine with path /remoteserver/005_S_0221/mpr/m1/I72128/dat/06A515T.dat... (3 Replies)
Discussion started by: avatar_007
3 Replies

9. UNIX for Dummies Questions & Answers

copying files from one location to another based on a list

I have a text list of about 3,000 file names (image files), which exist on a server and that I want to copy over to another location. I understand the Unix cp code, but what's the string to have it copy multiple files based on an external list? Many thanks! (4 Replies)
Discussion started by: rebornhonest
4 Replies

10. UNIX for Advanced & Expert Users

Copying files between 2 Unix server

Is there a simple way to copy data from one server to a different server? Seems that if 2 servers are on the same network, there should be a simple way to copy between the two. Not just one file. I need to copy a whole directory with subdirectories from one server to a different one. I... (9 Replies)
Discussion started by: Docboyeee
9 Replies
Login or Register to Ask a Question