Re: Re: Transferring files between computers using php
| From: | Ray Hauge | Date: | Fri, 07 Mar 2008 04:24:22 +0000 |
| Subject: | Re: Re: Transferring files between computers using php | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271114@lists.php.net to get a copy of this message | ||
Rahul wrote:
Zareef Ahmed wrote:I second the NFS mounting. You can share a directory somewhere on computer A. Then computers B and C connect to it. That way with PHP you just copy the file to the shares, and computers B and C automatically see the file there. Outside of that FTP might work well for you. Maybe even SCP, since you already have the keys on server A (as long as you don't have a password when connecting to B or C). rsync can work over SSH as well, and you could create a simple script to run rsync as often as you need. haha, I guess that's not exactly seconding NFS, more seconding not transferring files over HTTP. -- Ray Hauge www.primateapplications.comOn 3/7/08, Rahul <rahul986@gmail.com> wrote:Well I haven't ruled our webserver and ssh but I don't have much options. Number 1 is that I have many such computers and I don't think I can afford to install a webserver on all of them atleast. And coming to SSH, I can't use it because of the scenario that I explained. Please let me know if you have any other advice. Thank YouThank you all so much for replying... I guess I was very vague in describing the situation. I will write in detail: I have three computers A, B and C. To login to B and C I should use A because it has a SSH key. I don't have any other way of accessing these two computers. Now, if I need to transfer a file between B and C, I am unable to find a way that would work... because I don't know how to authenticate without SSH keys... I was gathering some data in B and C using PHP. Now, I need these two computers to coordinate a little and didn't want to use a server in between and so I was thinking of establishing a direct connection between them..If you have ruled out web server and ssh, then you can use ftp using PHP or use NFS mounting. Zareef Ahmed wrote:On 3/7/08, Shawn McKenzie <nospam@mckenzies.net> wrote:theRahul wrote:I have a small file to be transferred between two computers every few seconds. I'm using unix with a bare bones version of php, i.e. justwayoriginal thing that gets installed when I run "yum install php". Asthere isno webserver on any of these machines, I was wondering if there is aFedora)totransfer a small file between them and if there is, could someone bekindenough to provide me with an example please? Thank YouFYI... If you're using yum I assume it's a Linux machine (maybeat aand not Unix.If you want to use rsync and scp in a cronjob (for continuous transferpredefined interval), you may need to set your server (read ssh) toacceptconnection without password. Ref : http://linuxproblem.org/art_9.html BUT If you really want to do that from PHP, you can install a web serverandenable http as your stream for opening files. (In php.ini) You can read the file using fopen or any other file functions, then can write that file to the server on which script will be running, then youcanset this script as your cron job. For example : $filecontents=file_get_contents("http://firstserver/file.txt"); $fp=fopen("path to local file", "mode"); Now use $fiiecontents to write the file using $fp resource. BUT remember, using rsync is always a better solution, andfile_get_contentsand file functions are resource hungry, specially they will consume more memory of your system. ---- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpPHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php