Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

sending hexadecimal data via telnet

by Looserette (Initiate)
on Aug 07, 2012 at 13:11 UTC ( #985977=perlquestion: print w/ replies, xml ) Need Help??
Looserette has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I fear that's an easy question, but I just can't find the answer ... (maybe I'm not using the right words).

Here's a snippet of snoop output:

64: 8d5b ffff 3131 3931 3031 3030 3030 3032 .[..119101000 +002 80: 2e30 3130 3030 2020 2020 2020 2020 2020 .01000

=> I need to send that "0xffff" using Net::Telnet ... how can I do that ?

Thanks for your help !

Comment on sending hexadecimal data via telnet
Download Code
Re: sending hexadecimal data via telnet
by tobyink (Abbot) on Aug 07, 2012 at 13:16 UTC
    $telnet->put("\x{FF}\x{FF}");
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: sending hexadecimal data via telnet
by aitap (Deacon) on Aug 07, 2012 at 13:25 UTC
    Or use pack to transform arbitrary hexademical numbers into bytes. For example:
    $ echo -n deadbeef | perl -pe's/([[:xdigit:]]{2})/pack("H2",$1)/ge' | +xxd 0000000: dead beef ....
    Sorry if my advice was wrong.
Re: sending hexadecimal data via telnet
by thundergnat (Deacon) on Aug 07, 2012 at 19:07 UTC

    "\xff" is the Telnet IAC (Interpret As Command) character. If you want to send an actual "\xff" character as data, you need to double it; "\xff\xff" Since it seems you want two "\xff" bytes in a row as data, you need to send 4 "\xff" bytes. See RFC854 pages 13-14.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://985977]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2014-07-23 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (154 votes), past polls