On 3/7/08, Shawn McKenzie <[EMAIL PROTECTED]> 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
>
>


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

Reply via email to