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?
source to share
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
source to share