1

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;
}
Haru
  • 1,361
  • 2
  • 15
  • 40

1 Answers1

3

The control character for backspace is 0x08 (you can add it to a string in PHP as "\x08").

rid
  • 61,078
  • 31
  • 152
  • 193
  • Is there a list of these out on the net somewhere? – Haru Apr 18 '12 at 14:21
  • 1
    @and_27_y, sure, these are the [ASCII control characters](http://en.wikipedia.org/wiki/ASCII#ASCII_control_characters). – rid Apr 18 '12 at 14:24