1

I have a big problem with special characters of Perl.

I'm trying to establish a Telnet connection.

So, after the command "Telnet $ipAddress" I have to send the credentials.

I have done this way:

my $exp = new Expect;

$exp->send("username");
$exp->send("@password");

The problem is that my password has the @ character as first character and it is a special character.

I have already tried with '@password', "\@password" or "\\@password", but the login fails.

How can I get my password to work?

pynexj
  • 19,215
  • 5
  • 38
  • 56
A. P.
  • 11
  • 1
  • Try putting it in single quotes `'@password'` – xxfelixxx Aug 02 '16 at 03:15
  • Have you tried setting `$Expect::Exp_Internal = 1;`? I'm no expert on Expect but I'd, uh, expect it to be rather brittle when faced with programs like telnet that want to talk to a terminal and do fancy things like turning echo on and off. If `@` is in any way special to Expect, perhaps you need `"\\\@password"` or, simpler, '\@password'. Failing that, communicating with the service yourself using `Net::TCP` or something may be more robust. – mbethke Aug 02 '16 at 04:55
  • I have already tried with single quotes, but it doesn't work. – A. P. Aug 02 '16 at 08:33
  • Thanks for the advice, I have tried to set $Expect::Exp_Internal = 1; and I saw that anyway my script send the correct password. – A. P. Aug 02 '16 at 08:35
  • But the login fails. I don't know why. Thank you anyway for your help. – A. P. Aug 02 '16 at 08:35

0 Answers0