Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2008
    Posts
    9

    Unanswered: Secure copy only a certain type of files with out knowing the name of subdirectory

    Hello Gurus,

    I am kind of new to shell scripting , is there any way we can secure copy only certain type of files without knowing the name of the sub directory

    ex: i have a directory called dir1 which changes its name based on the date and under that we have another sub directory which can ab , bc or cd and in those directories i i have pdf files which in need to get from source to destination.

    Thank you in advance

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You don't mean something like this?
    Code:
    scp user@host:/some/dir/*/*/*.pdf ...
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Apr 2008
    Posts
    9
    Quote Originally Posted by stolze
    You don't mean something like this?
    Code:
    scp user@host:/some/dir/*/*/*.pdf ...

    Exactly That is how i need

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Code:
    scp user@host:/some/dir/*/*/*.pdf ...
    This may not work if the number of files is sufficiently large. I'd go with
    Code:
    find /some/dir -name "*.pdf" -exec scp '{}' user@host:/target/dir/ \;
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Apr 2008
    Posts
    9
    Quote Originally Posted by n_i
    Code:
    scp user@host:/some/dir/*/*/*.pdf ...
    This may not work if the number of files is sufficiently large. I'd go with
    Code:
    find /some/dir -name "*.pdf" -exec scp '{}' user@host:/target/dir/ \;

    Hello n_i,
    I need to copy from a remote site , will this work

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Yes, if you don't do a pull from the remote host but rather a push. For that, you use the "find ..." as command for ssh.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  7. #7
    Join Date
    Apr 2008
    Posts
    9
    Quote Originally Posted by stolze
    Yes, if you don't do a pull from the remote host but rather a push. For that, you use the "find ..." as command for ssh.
    Thank you guys, really appreciate your help

  8. #8
    Join Date
    Apr 2008
    Posts
    9
    Quote Originally Posted by sumanchal
    Thank you guys, really appreciate your help
    need one more help, when you do ssh, how are we going to put the find and scp part.

    Thanks in advance

  9. #9
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Another idea is to use ssh to get a list of files (via a find at the remote system), then scp to get those files:
    Code:
    for f in `ssh user@host "find /some/dir/ -name "*.pdf"`; do
        scp user@host:$f /some/local/dir
    done
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  10. #10
    Join Date
    Apr 2008
    Posts
    9
    Quote Originally Posted by stolze
    Another idea is to use ssh to get a list of files (via a find at the remote system), then scp to get those files:
    Code:
    for f in `ssh user@host "find /some/dir/ -name "*.pdf"`; do
        scp user@host:$f /some/local/dir
    done
    hello stolze,
    i am getting this error, command substitution: line 1: unexpected EOF while looking for matching `"'

  11. #11
    Join Date
    Apr 2008
    Posts
    9
    Quote Originally Posted by sumanchal
    hello stolze,
    i am getting this error, command substitution: line 1: unexpected EOF while looking for matching `"'

    Hello Stolze, Thank you very very much, really appreciate your help, double quote was missing, is there any way that i can give the password only once when i connect using ssh, it is asking every time bcoz of the loop

Posting Permissions

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