PHP Apache Unix open / write files on different server

I'm familiar with writing and reading files located on the same server that my PHP or Perl script is running, but what if I needed to write/read files located on a different server?  Server A needs to write to and read content on Server B.  (I have permissions to read and write on both Server A and Server B.)  

In the case of PHP, would I use fsockopen or fopen?  Can you give examples of a simple read/write in Perl and/or PHP where the script, executing on Server A (10.10.10.1), is reading/writing to Server B (10.10.10.2) assuming all permissions are set up correctly?

Thank you,
$marc

LVL 3
marcparilloAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OscurochuCommented:
There really is no way to write to a different server with PHP... what I would do is just create a script on server A that sends the data to server B, and the script on server B writes the data received. vice-versa.
0
marcparilloAuthor Commented:
So Server A sends the data to Server B via POST and Server B just waits for the data?
0
OscurochuCommented:
pretty much
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

marcparilloAuthor Commented:
What about the PHP function fopen?  I noticed in the on-line PHP manual this example that looks like the protocol for writing to a file on a different server:

("ftp://user:password@example.com/somefile.txt", "w");

0
OscurochuCommented:
You can read files from a different server but you cannot write to a different server.
0
marcparilloAuthor Commented:
If that was the case, then why would the PHP manual show an example of an fopen function that appears to be able to write to a different server via FTP?  

Am I not understanding this correctly?
0
OscurochuCommented:
You can use fopen to write to an FTP server, I forget about that. That is the only way to write to a different server. Sorry, my mistake.

Please refer me to the php manual page you are talking about if that does not end your confusion.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.