is this possible? for example i have a text file (sample.txt) hosted at webhosting A. i want this file to be accessed and modified by site1(hosted at webhosting B) and site2(hosted at webhosting C). How do i do this? Thanks for any input.
You should be able to do this, but you might have to have some form of connection between the servers such as SSH. If you are then opening the servers to SSH you want to restrict access to it by iptables and authorized keys. However this option is only really open to dedicated hosts or if you host the servers yourself, a lot of companies that only sell web hosting will not provide facilities such as SSH without going dedicated.
Hi, I think the best way of achieving this would be to implement a REST method on the server where the file is held. If you want to add to the sample.txt on server A, I suggest you create a PHP script that respond to a form. Then from server B, you call that script with curl and pass whatever info you want to add to the text file. That way server A will get the request, open the file and append to it efficiently. You could also make sure server B is calling server A by checking the IP or the referrer. There are many ways of doing it, but I doubt any server will let you modify a text file remotely as this is a huge security risk aXe
I only know how to do this for a Unix OS though. <?php $output1 = shell_exec("shell command here"); $output2 = shell_exec("shell command here"); echo $output1; echo $output2; ?> PHP: Shell command you want is: rsync -Pv <location of file to move> <account>@<ip address>:<file location> Code (markup): So an example would be... rsync -Pv /usr/bin/script.sh That would move the file script.sh from the host server to the same location on the 192.168.0.1 server using the root account. Hope this helps.
The nature of the alterations can make a difference, but in a nutshell; You would use the SSH2 functions to create a lock file, check the creation time of all lockfiles present, if the scripts lockfile is the oldest it makes updates to the file, then deletes it's own lockfile. If it doesn't have the oldest lockfile it immediately deletes it's own lockfile and tries again in N seconds.
thanks for all your replies! i finally found a way using just php and just two different hosting. i actually don't need a third one. i tried SSH2 but i think you need a root access to do that.