Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am having two domains and i need to copy some file from one domain to another.

cp  http://domain1.com/test.xml http://domain2/crontest/

I tried above but it dint work. Is there any other way?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The Unix/Linux cp command uses filesystem paths, not URLs.

If the two domains are served from the same server, and you have admin access to the whole server (it is not hosted by a hosting company) you can do the copy by converting the URLs to filesystem paths by prepending the document root "docroot" for each site to the path portion of the URL.

If the docroot for domains 1 and 2 is /var/www/domain1 and /var/www/domain2

 cp /var/www/domain1/test.xml /var/www/domain2/

If the sites are on separate servers and you have ftp access to at least one and shell access to another, you can just use ftp

  $ cd /var/www/site1
  $ ftp server2.example.com
  user: mubasshir
  password: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  > cd relativedocroot
  > get test.xml
  > quit

You can script this for cron - read the manpage


Instead of using ftp you can also use wget

  $ cd /var/www/site1
  $ wget http://domain2/crontest/test.xml
share|improve this answer
    
no they are not same server. –  Mubasshir Pawle Jan 24 '12 at 14:07
1  
@mubasshir: see updated answer - I'd use wget. –  RedGrittyBrick Jan 24 '12 at 14:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.