Home Page
  • May 21, 2024, 03:25:25 am *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  


Official site launch very soon, hurrah!

Author Topic: Telnet Workaround  (Read 9354 times)


  • Programmer Person
  • Administrator
  • Hero Member
  • *****
  • Posts: 537
    • View Profile
    • Dakusan's Domain
Telnet Workaround
« on: September 28, 2009, 05:32:18 am »

Original post for Telnet Workaround can be found at https://www.castledragmire.com/Posts/Telnet_Workaround.
Originally posted on: 01/17/09

I recently had to do some work on a system where I was not allowed SSH/telnet access. Trying to do work strictly across ftp can take hours, especially when you have thousands of files to transfer, so I came up with a quick solution in PHP for simple command line access.

<form method=post action="exec.php">
   <table style="height:100%;width:100%">
      <tr><td height="10%">
         <textarea name=MyAction style="height:100%;width:100%"><?=(isset($_REQUEST['MyAction']) ? $_REQUEST['MyAction'] : '')?></textarea>
      </td></tr><tr><td height="90%">
         <textarea name=Output style="height:100%;width:100%"><?
   $MyAction=preg_split("/\\r?\\n/", $_REQUEST['MyAction']);
   foreach($MyAction as $Action)
      exec($Action, $MyOutput);
      print htmlentities(implode("\n", $MyOutput), ENT_QUOTES, 'ISO8859-1')."\n-----------------------\n";
      </td></tr><tr><td height=1>
         <input type=submit>

This code allows you to enter commands on separate lines in the top box, and after the form is submitted, the output of each command is entered into the bottom box separated by dashed lines.

Note that  between each command the environment is reset, so commands like "cd" which change the current directory are not useable :-(. You must also change the line 'action="exec.php"' to reflect the name you give the file.

A more suitable solution would be possible through AJAX and a program that redirected console output from a persistent session, but this was just meant as quick fix :-).