Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unanswered: 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

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    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.

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    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

  5. #5
    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

  6. #6
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    You seem to be missing the "tail -1" from the previous example.

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

    Mike

  7. #7
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •