Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hello everybody I am using net::telnet to connect to a server and I need to send control-X to the server, if I monitor the telnet session I can see that when control-X is pressed, hex 18 is sent to the server, I have not been able to get my script to send this, if I try 0x18, it is automatically converted to decimal 24 and '24' is sent, if I try '0x18', then that is literally sent, I have tried sending '\4' and this correctly sends the control-d character, but if I send '\24' then again '24' is sent, I have also tried '\cX', (from regexp \c meaning control character) but no go, could somebody please kindly point me to the solution to this rather stoopid problem, thank you

Replies are listed 'Best First'.
Re: sending control characters
by Mr. Muskrat (Canon) on Jul 31, 2003 at 17:04 UTC

    It sounds like you are sending only numeric data and not characters. Perhaps you should send chr(24).

    Update: How are you sending the control-X characters? I suspect that you are enclosing the strings in single quotes like in your write up which is not the same as having them enclosed in double quotes.

    The following all print control-X characters locally (I cannot test via Net::Telnet at the moment).

    print chr(24),"\n"; print "\x18\n"; print "\cX\n"; print "\30\n"; # that's 24 in octal ;-)

      thank you very much for the fast response, chr(24) did the trick I was using double quotes despite what I wrote in the article, but chr() does the trick so I will not mess with any further again, thank you for your help