in reply to How can I send Ctrl-D over Telnet session

ctrl-d is just the byte 0x04 (just like space, character 32, is the byte 0x20), so in perl, ^D is "\x4".

So just put a "\x4" in your string where you want the ctrl-D, or even better:

# also declare other ctrl chars you need... my $ctrlD = "\x4"; my $escape = "\x1b"; #... more code here... cmd("Send all the\ncommands you need\nincluding a ${ctrlD}");

Mike

Replies are listed 'Best First'.
Re^2: How can I send Ctrl-D over Telnet session
by tye (Sage) on Sep 10, 2008 at 14:19 UTC

    Since asked for CTRL-D, I'd use "\cD" instead.

    - tye        

      That works... I didn't know that escape, thanks!

      Mike
Re^2: How can I send Ctrl-D over Telnet session
by Anonymous Monk on Sep 10, 2008 at 09:53 UTC
    C:\>perl -e"print qq,\cD," ♦ C:\>perl -e"print qq,\cD," |hexdump 00000000: 04 - | | 00000001; C:\>perl -e"print qq,\cD," |od -tacx1 0000000 eot 004 04 0000001 C:\>