LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2012, 12:02 AM   #1
richa_s
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Rep: Reputation: Disabled
File Transfer


Hi,
I'm new to unix, and creating a script to transfer files.
I am able to do so using scp.

Issue is I want to transfer files from a directory located at different unix server and to a directory located at another unix server.

Can any one please help me?

Thanks in advance!
 
Old 01-05-2012, 12:13 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
That's a bit of a short qn, but as per docs http://linux.die.net/man/1/scp
Code:
scp user1@host1:/dir1/file1 user2@host2:/dir2/file2
 
Old 01-05-2012, 12:24 AM   #3
richa_s
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Unhappy

Thanks Chris!

Command you specified above is working fine.
But my script is demanding something else.

I'm trying to find all the files in a directory of another server, using below command:

find server:/path/ -type f

After getting the result i will need to place few more filter then i would need to transfer filtered files at a location.

But find cmd prompts with an error: find: stat() error server:/path/: No such file or directory.
 
Old 01-05-2012, 07:05 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
'find' only takes a dir as the search path.
The easiest way to do what you want (assuming I understand requirement), is to login to box1 and do your filtering there, saving file list into a file list (sic), then
Code:
for filename in `cat files.lst`
do
    scp $filename user2@host2:/dir2/$filename
done
NB: untested and assumes no spaces or ctrl chars in filenames.
That should get you started. You may need these links
http://linux.die.net/man/
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

Note also that you'll need any reqd dirs to already exist on the target.
 
Old 01-06-2012, 01:19 AM   #5
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
I am not very clear about what you are asking.

Please correct me if I am wrong

You are trying to filter some files inside one directory and then copy those files from that particular server to another server?

If this is what you are trying to do then you can simply move all those filtered files into any directory and then copy it to your client machine

Code:
#find / -type f exec cp {} /files/ \;
this will move all your filtered files to /files directory

then

Code:
#scp -rvf /files/* 192.168.0.XX:/path/to/dir/
or I prefer using rsync
Code:
#rsync -avh /files/* 192.168.0.XX:/path/to/dir
if you want the current files to be deleted after copying
Code:
#rsync -avh -delete /files/* 192.168.0.XX:/path/to/dir
 
  


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
Sony PSP file transfer inaccurate transfer progress stratotak Linux - Newbie 3 01-02-2010 03:49 AM
file time stamp is wrong with ssh file transfer cy163 Linux - Newbie 8 05-18-2008 01:40 AM
Gnome/Nautilus issues Beagle-Tracker, file transfer info, replace file info, popup. Mysticle31 Linux - Software 0 01-08-2008 05:30 PM
transfer dvds from ogg file to vod file kingfish217217 Linux - Software 3 02-19-2007 06:19 PM
File Transfer thereeper Linux - Software 2 05-17-2005 05:26 PM


All times are GMT -5. The time now is 01:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration