Rahul wrote:
Zareef Ahmed wrote:
On 3/7/08, Rahul <rahul986@xxxxxxxxx> wrote:
Thank 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@xxxxxxxxxxxxx> wrote:
Rahul 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. just
the
original thing that gets installed when I run "yum install php". As
there is
no webserver on any of these machines, I was wondering if there is a
way
to
transfer a small file between them and if there is, could someone be
kind
enough to provide me with an example please?
Thank You
FYI... If you're using yum I assume it's a Linux machine (maybe
Fedora)
and not Unix.
If you want to use rsync and scp in a cronjob (for continuous transfer
at a
predefined interval), you may need to set your server (read ssh) to
accept
connection without password.
Ref : http://linuxproblem.org/art_9.html
BUT If you really want to do that from PHP, you can install a web
server
and
enable 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 you
can
set 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, and
file_get_contents
and 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.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
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 You
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.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php