title: Laravel - Linux(ubuntu) Real-time process and show output on webpage(blade)
body: <p>I want to get the real-time output of a running process on my server. For the script I made something simple in bash:</p>
  
  <p>Script 1 (script.sh).</p>
  
  <pre><code>#!/bin/bash
  
  y=0;
  
  while [ $y &gt; 0 ]; do
  y=$((y+1))
  sleep 1;
  echo $y
  echo "I am baking pies. I have $y so far."
  done
  </code></pre>
  
  <p>Script 2 (test.sh).</p>
  
  <pre><code>#!/bin/bash
  
  ~/script.sh &gt; /dev/null &amp;
  pid=$!
  
  echo $pid
  strace -e trace=write -s1000 -fp $pid 2&gt;&amp;1 \
  | grep --line-buffered -o '".\+[^"]"' \
  | grep --line-buffered -o '[^"]\+[^"]' \
  | while read -r line; do
  printf "%b " $line;
  done
  </code></pre>
  
  <p>The second script's role is to run the first one, get it's pid and than trace the output of that pid. On the server side this should be enough but I may be wrong. However, on the laravel side I couldn't figure a way to get the live output of that script.</p>
  
  <p>Laravel, using Symfony (using the Symfony Docs example: <a href="https://symfony.com/doc/current/components/process.html" rel="nofollow noreferrer">https://symfony.com/doc/current/components/process.html</a>).</p>
  
  <pre><code>$process = new Process(['/test.sh']);
  $process-&gt;run();
  
  // executes after the command finishes
  if (!$process-&gt;isSuccessful()) {
      throw new ProcessFailedException($process);
  }
  
  echo $process-&gt;getOutput();
  </code></pre>
  
  <p>The script works almost like it should be, but there is a problem:</p>
  
  <p>When the script runs laravel only prints the pid and doesn't wait for the output of the strace command. Now, is there a way to get the live output of the script while it is running? If it is not possible using Laravel and Symfony alone could I achieve it by using VueJS (which I am familiarized with and practiced in the past few months)?</p>