Re: Re: Transferring files between computers using php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
>
>


-- 
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux