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

I'm creating a perl script on RH 6.2 that will connect to a server and send a username and password. The sever expects the folllowing... <control b> username,password<control c> . The server then sends back confirmation. Well i'm having trouble sending the keyboard equivalent of <crtl B> and <crtl c>. I've tried $var = chr(02) ... send SOCKET, 0, 0, $var. But it doesn't work. Now the catch is that when I use Hyperterminal on my Win box and I hit <control b> username,password<control c> , <control b> is a smiley face and <control c> is a heart, and I log on fine. Perl's $var = chr(02) seems to produce ^B. How can I get my perl script to send the heart and smiley face? Or better yet, what the heck is goin' on? Thanks. Vic

Replies are listed 'Best First'.
Re: Trouble connecting To Server
by Beatnik (Parson) on Jun 19, 2001 at 19:48 UTC
    \cX mimics CTRL- behaviour...
    \cB for CTRL-B, \cC for CTRL-C.
    BTW this stuff is mentioned in perlop.

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      I tried the \cB and \cC, but it still doesn't work. I think this has something to do with the way I'm sending the data. Again, typing everything in HyperTerminal works fine. Is there some "Perl terminal emulation mode"? -- whatever that means. Does terminal emulation send data in a "special/different" way than IO:SOCKET?

      -about to go nuts-
      Vic

        Did you try just sending the ascii value of ctrl-c? Maybe using pack? (print \002; works too, no?)
      Thanks for your help guys. I got it work. It was indeed the \c character that solved the issue.
Re: Trouble connecting To Server
by Anonymous Monk on Jun 19, 2001 at 21:20 UTC
    Connect Hyperterminal to your Perl program (Socket modified to listen) and *read* the shit that comes out of the sewer. And it could make a difference if you send \cB in one Block and \cC in the next or if they are in the same Block.