I need to create a php script that connects to a remote linux box and retrieves data. But I need it to continually run as the data will be updated very often. I plan on storing the data in a database but I need to get around this problem first.
The plan is when I go to the site the script would run and keep the database up to date.
I've included the code im working from.
Thanks for the help
<?php
if($ssh = ssh2_connect('127.0.0.1', 22))//If it connects
{
if(ssh2_auth_password($ssh, 'user', 'password'))//User and password to use
{
$stream = ssh2_exec($ssh, 'cat -e /home/jason/Desktop/test');//command to execute
stream_set_blocking($stream, true);
$data = '';
while($buffer = fread($stream, 4096))//read from stream
{
$data .= $buffer;
echo $data; //output results
}
fclose($stream);//close stream
}
}
?>
This post has been edited by compactbrain: 19 January 2012 - 05:34 PM

New Topic/Question
Reply



MultiQuote






|