Laravel SSH Ouput not returning full output content

I am using the following code using Laravel 4 and SSH command.

SSH::into('runtime')->run(array(
   'cd /home/ubuntu',
   './update.sh'
), function ($line){

   echo $line.PHP_EOL;

});

      

The SSH command works absolutely fine and the contents of the file are update.sh

run. However...

If I run the update.sh script from the command line, the output is as follows:

Already up-to-date. (This part of the message depends on the output of git pull)
Stopping nginx: nginx.
Starting nginx: nginx.

      

What I get when running the Laravel code:

nginx.

      

Is there a way to get the full output or does Laravel trim it anyway?

+3


source to share


2 answers


The problem was that update.sh

3 commands were run in, and the Laravel SSH function was only returning the last part of the output, since the variable I was using to capture was being overwritten all the time.

I created a private variable in my class:

private $output;

      

Then changed my SSH startup code to:



SSH::into('runtime')->run(array(
   'cd /home/ubuntu',
   './update.sh'
), function ($line){

   $this -> output .= $line.PHP_EOL;

});

      

So, for this I add the output $line

to my output variable. Then I can access my result using:

echo $this -> output;

All printed

0


source


Try adding a redirect to the command to send stderr to stdout.



SSH::into('runtime')->run(array(
    'cd /home/ubuntu',
    './update.sh 2>&1'
), function ($line){
    $this->line($line);
});

      

+1


source







All Articles