title: PHP SSH terminal inside Screen session
body: <p>I'm trying to use libssh2 to send commands to connect to a Screen session on a CentOS box, (1) grab everything that's on the current page and then (2) allow the user to execute commands and grab the output of those commands.</p>
  
  <p>I have explored a couple of approaches to get to this work, first by connecting the screen session and second by sending commands to the screen session.</p>
  
  <p>For (1) I still have no idea how to do this. I'm looking for a Shell equivalent to print screen I guess, so that I can run the command inside PHP and grab the output and write it to the PHP output.</p>
  
  <p>For (2) I've tried various permutations of the following:</p>
  
  <pre><code>screen -S `ls -1 /var/run/screen/S-root` -p 0 -X pwd
  </code></pre>
  
  <p>To try and run pwd inside a screen session (there is an assumption that there is only one running), but no output is returned, and when connecting to the screen session manually, I don't see my command run.</p>