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

04-17-08, 09:52
|
|
Registered User
|
|
Join Date: Apr 2008
Posts: 9
|
|
|
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
|
|

04-17-08, 11:12
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
You don't mean something like this?
Code:
scp user@host:/some/dir/*/*/*.pdf ...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
|
|

04-17-08, 11:24
|
|
Registered User
|
|
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
|
|

04-17-08, 11:28
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,452
|
|
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/ \;
|
|

04-17-08, 11:36
|
|
Registered User
|
|
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
|
|

04-17-08, 13:16
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
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
|
|

04-17-08, 15:48
|
|
Registered User
|
|
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
|
|

04-18-08, 11:40
|
|
Registered User
|
|
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
|
|

04-18-08, 13:07
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
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
|
|

04-18-08, 13:36
|
|
Registered User
|
|
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 `"'
|
|

04-18-08, 14:04
|
|
Registered User
|
|
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
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|