Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying directory in another server

Status
Not open for further replies.

ranjank

IS-IT--Management
May 9, 2003
176
IN
Hi,

I want to copy a particular file in the directory to another server.In the script i'm using scp option.Is there any way to create directory in another server thru script.

e.g

scp /abc/xyz root@10.1.1.1:/pqr/

I want to copy /abc/xyz in /pqr directory in another server.

Any help will be highly appreciated.

Regards,
RK.
 
You can use the scp -r switch to copy the contents of /abc/xyz including its subdirectories.

But to make the /pqr directory on the destination you will need to run a separate command first, for example ssh root@10.1.1.1 mkdir /pqr.

Annihilannic.
 
Why not create the directory on the server your copying from move the file you want to copy into that directory. Then use the -r to recusively copy the directory & file over.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Another option
Code:
cat /abc/xyz | ssh root@10.1.1.1 "[[ -d /pqr ]] || mkdir /pqr; cat > /pqr/xyz"

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top