title: get screen id via ssh in php
body: <p>I am trying to run a lengthy command from a remote server on php using screen, but i want to make sure that the screen is killed at the end of the command. So i am trying to use "echo $STY" to get the screen id and kill it that way. for some reason, this is not working. Any ideas:</p>
  
  <pre><code>ssh2_exec($conn, 'screen');
      $getscreen =ssh2_exec($conn, 'echo $STY');
      stream_set_blocking($getscreen, true);
      $stream_outA = ssh2_fetch_stream($getscreen, SSH2_STREAM_STDIO);
      $valA =fgets($stream_outA,160);
      $scrnids =explode('.',$valA);
      var_dump($scrnids);
      $killcommand = 'screen -X -S '.$scrnids[0].' kill';
         $stream = ssh2_exec($conn, $command);
         .....
  
      ssh2_exec($conn, $killcommand); 
      ssh2_exec($conn, 'exit'); //just in case
      unset($conn);
  </code></pre>
  
  <p>the var dump just outputs:</p>
  
  <pre><code> array (size=1)
    0 =&gt; string '
    ' (length=1)
  </code></pre>