![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| copying directories from NT server to Unix server (solaris 5.8) | jhmr7 | UNIX for Dummies Questions & Answers | 4 | 08-07-2008 10:53 PM |
| Copying multiple folders to local machine (don't know folder names) | leenyburger | UNIX for Dummies Questions & Answers | 5 | 06-12-2008 04:38 AM |
| decompressed files to specific folders | c00kie88 | Shell Programming and Scripting | 3 | 04-06-2008 02:41 PM |
| Copying specific files | faaron3 | UNIX for Dummies Questions & Answers | 3 | 03-24-2008 10:59 AM |
| Copying Folders without some folders... ;-) | chimpu | UNIX for Dummies Questions & Answers | 5 | 04-26-2004 09:25 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Copying specific folders from one server to another
Hey Guys,
After doing some searching on google i still cannot find a specific answer. May be its because my lack of skills in unix. If ayone can help me out or give me a psuedo code i really appreciate it. I have one unix server ABC. The folders which i am trying to access is :- /home/web/dummy. Now in dummy folder i might have 2 or 5 different folders something like this: /home/web/dummy/mike/images /home/web/dummy/mike/source /home/web/dummy/mike/testing /home/web/dummy/john/images /home/web/dummy/john/source /home/web/dummy/john/testing /home/web/dummy/alex/images /home/web/dummy/alex/source As you can see under dummy folders i have 3 different folders. But the folder which i am concern about is (testing) folder. So mike and john have testing folder, images and source. I would like to write a script which will have a path of :- /home/web/dummy after dummy it will check each and every directory. so first is john it will see if john has testing folder. if john have testing folder then it will copy to my another unix server which is XYZ. So in server XYZ i would like to store the files over here :- /home/manage/ so if john contains the folder testing then it will copy to my XYZ server :- /home/manage/john/testing As you can see i dont want to copy images or source folder. People with testing folder will be only copied. Any guidance on how to achieve it. I know the command tocopy the directory from one server to another but dont know how to achieve this task. Thank You |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Ok. I tried one thing and i just got the 1st part solved.
Code:
find /home/web/dummy -type f | grep "testing" Code:
/home/web/dummy/mike/testing /home/web/dummy/john/testing /mike/testing /john/testing to my XYZ unix server. How"? |
|
#3
|
||||
|
||||
|
Are you looking to copy over the entire directory (including content)?
Something like this: Code:
cd /home/web/dummy
for dir in *; do
if [ -d ${dir}/testing ]; then
ssh -l user otherhost "mkdir /home/manage/$dir
scp -r ${dir}/testing user@otherhost:/home/manage/$dir
fi
done
|
|
#4
|
|||
|
|||
|
Mr Torch,
Can i guve you some dukes Dollars ? ;--) Thank you so much. It works perfectly. Just 2 more things to ask may be you can tell me and i can do it. if not then i will post back. Yes i need to copy the contents under testing folder also. The script is doing that. Say for instance i have :- /home/web/dummy/mike/testing/check.txt /home/web/dummy/john/testing/test.txt when i run the script the first time it copies /mike/check.txt /john/test.txt The second time i run the script and then it does like this: /mike/testing/check.txt /john/testing/test.txt As you can see i would like to have the testing folder also in there. But for some reason it creates the folder the second time i run. Not a biggie i wil try to figure it out. Thanks anyways |
|
#5
|
|||
|
|||
|
Ok this is the code i am using:
[code] cd /home/web/dummy for dir in *; do if [ -d ${dir}/testing ]; then #ssh -l user otherhost "mkdir /home/manage/$dir scp -r ${dir}/testing user@otherhost:/home/manage/$dir fi done [code] I tried to change everything i can to make it work but unfortunately i have not succeeded yet. When i run the script the first time it just copies whatever is in testing folder but when i run the code second time everything works fine. My Question is why this is not working the first time when i run my script? it just copies the contents of testing folder rather than creating a testing folder in XYZ server. Any help will be really appreciated. |
|||
| Google The UNIX and Linux Forums |