I tried to write some script that will allow me automatically download log files from my linux router to the other linux machine. Everything worked fine, until I some errors while downloading the file poped up.
It happens always, usually after 2min after start the script. Of course, theres no even a part of downloaded data. Log files "weights" around 60MB each. Maybe someone could help me rewrite this script or explain what Im making wrong.
here`s the error message.
warning: stream_set_blocking(): supplied argument is not a valid stream resource...
and that`s the part of code, that should download the file/files
<?php
$stream = ssh2_scp_recv($shell, '/var/log/'.$file_name, $file_name);
stream_set_blocking($stream, true );
stream_set_timeout($stream, 1600);
while($buffer = fread($stream, 8192))
{
$data .= $buffer;
}
?>