If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > SCP the latest file from the remote host

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-07-09, 04:22
spkandy spkandy is offline
Registered User
 
Join Date: Aug 2009
Posts: 3
SCP the latest file from the remote host

Hi All,
Greetings for the day..

I just want to secure copy a latest data file from the remote host.
Is there any option available in 'SCP'?
I am using ssh key-authentication, so SCP/SSH is the only option.
Please help me..

Cheers,
Kandy
Reply With Quote
  #2 (permalink)  
Old 08-07-09, 07:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I would use "ssh" and "find" to find the latest file, get the name from it and then apply this to "scp" to get the file.

If you want to use this mechanism to update a local copy, would "rsync" be an option for you?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 08-07-09, 11:22
spkandy spkandy is offline
Registered User
 
Join Date: Aug 2009
Posts: 3
SCP the latest file from the remote host

Hi Stolze,
Thanks a lot for your suggestion..!
Can you please explain something more.
Reply With Quote
  #4 (permalink)  
Old 08-07-09, 15:01
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool ssh | scp

Try somethng like this:
Code:
ssh remote1 "ls -tr /my/file/dir|tail -1"|xargs -i+ scp remote1:/my/file/dir/+ .
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #5 (permalink)  
Old 08-08-09, 03:44
spkandy spkandy is offline
Registered User
 
Join Date: Aug 2009
Posts: 3
Red face SCP the latest file from the remote host

Hi LKBrwn_DBA,
I tried the below code, but it throws the syntax error.
Can you please corect me..

ssh <UID>@<HOSTNAME> "ls -tr /Parent/child/myfile*|xargs -i+ scp <UID>@<HOSTNAME>:/Parent/child/+ /MyDirectory/

Thanks,
Kandy
Reply With Quote
  #6 (permalink)  
Old 08-08-09, 05:27
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
You seem to be missing the "tail -1" from the previous example.

It would help if you actually gave us the error message.

Mike
Reply With Quote
  #7 (permalink)  
Old 08-10-09, 10:06
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool Tail and quote

You are missing the 'tail -1' and closing double quote:
Code:
ssh <UID>@<HOSTNAME> "ls -tr /Parent/child/myfile*|tail -1"|xargs -i+ scp <UID>@<HOSTNAME>:/Parent/child/+ /MyDirectory/
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On