I'm using this nice piece of code to connect to a Telnet session and send it some commands and get the output.
http://www.geckotribe.com/php-telnet/
I'm running into an problem now in that I want to remove some data in the Telnet session and replace it with some other data. (Not sure if that is possible or not??)
For an example: It prompts continue N - and I need to erase that N and place a Y there.
This function sends the command...Notice the \r, is there something that would simulate a backspace or delete?
function DoCommand($c,&$r) {
if ($this->fp) {
fputs($this->fp,"$c\r");
$this->Sleep();
$this->GetResponse($r);
$r=preg_replace("/^.*?\n(.*)\n[^\n]*$/","$1",$r);
}
return $this->fp?1:0;
}
The control character for backspace is 0x08
(you can add it to a string in PHP as "\x08"
).