in reply to Extra Character from telnet

To help you on this it would be useful if you did something like
(my $hex_user=$user)=~s/(.)/sprintf("%02x",ord($1))/egs; print "User: '$user' = '$hex_user'\n";
For both $user and $password. Then we could see what is up properly. Im guessing however that is due to $/ being different from what TELNET thinks is a newline. Its quite possible that your OS thinks $/ is "\x0A" and Telnet thinks that \n is "\x0D\x0A" and since chomp only removes $/ from the end of a line it doesnt get the "\x0D". If this is so then
$user=~s/\x0D\x0A$//;
Probably would be the solution.

UPDATE: Oops, didnt notice that you were on Win32. In this case I suspect its a similar problem, but with different values, ie not "\x0D\x0A". Show use the hex output of what you've got for the user value eh..

HTH

--- demerphq
my friends call me, usually because I'm late....

Replies are listed 'Best First'.
Re: Re: Extra Character from telnet
by AcidHawk (Vicar) on Dec 06, 2002 at 12:53 UTC

    This is running as a win32 service so I hade to output the print to a log file, this is what the code looked like...

    (my $hex_user=$user)=~s/(.)/sprintf("%02x",ord($1))/egs; &Update_Log("User: '$user' = '$hex_user'\n");
    This is what I got...
    14:46:07 - User: 'sriley ' = '7372696c65790d'
    hmmmm ... there is a little square after sriley that seems to translate to a lot of spaces..? in this node. The return should all appear on 1 line..

    Something like 14:46:07 - User: 'sriley^'= '7372696c65790d' the ^ is where that square is...

    -----
    Of all the things I've lost in my life, its my mind I miss the most.
Re: Re: Extra Character from telnet
by AcidHawk (Vicar) on Dec 06, 2002 at 13:09 UTC

    Ok, I put the test before the chomp and now I no longer get the little square but what looks like a carriage return.

    15:5:52 - User: 'sriley ' = '7372696c65790d0a'

    -----
    Of all the things I've lost in my life, its my mind I miss the most.
      Ok, so there's a confusion what the end of line is here. The telnet client is sending a CRLF, and when you chomp it, you end up (for some reason) with only the CR. You could try messing with $/ to get chomp to cut off both chars. See perlvar for more details.

      -- Dan