LaravelCollective / remote

Remote SSH Access for the Laravel Framework
MIT License
276 stars 106 forks source link

Catch output in a variable #47

Open PV-Patrick opened 7 years ago

PV-Patrick commented 7 years ago

Is it possible to catch the output of the command in a variable to be used elsewhere in the method?

Instead of echo $line.PHP_EOL; --> $str .= $line; ?

ewstefan commented 7 years ago

I'm currently having problems getting the closure to be called at all.

However, I would expect the following to work:

$response = '';

SSH::into('sftp')->task('myTask', function($line) use(&$response)
{
$response = $line;
});

return $response;
PV-Patrick commented 7 years ago

Thank you @ewstefan !! That worked!