Expect.pm send trims the number sign

74 Views Asked by At

I'm trying to use Expect.pm on an old machine with perl 5.8.8. It works but when I send a text that contains a "#" sign it is removed from the text. Is there a way to escape/protect it?

Thanks

Sorry corrected it is 5.8.8

#!/usr/bin/perl
use Expect;
use IPC::Open2;
my $cmd="./rec";
my $e = Expect->new;
$e->debug(0);
$e->spawn($cmd) or die;
$e->log_stdout(1);
$e->raw_pty(0);
my $cmd="#some command";
print "cmd: [$cmd]\n";
$e->send($cmd);
$e->expect(1,
  [ qr/^I:.*/ => sub { my $exp = shift; print "ok\n"; exp_continue;}],
  [ qr/^E:.*/ => sub {
        my $self = shift;
        print "ko\n";
        print "Match: <\n", $self->match, "\n>\n";
        print "Before: <", $self->before, ">\n";
        print "After: <", $self->after, ">\n";
        exp_continue;
        }]
  );
print "closing\n";
$e->clear_accum();
$e->close();

the rec is a simple c program chat echoes what it receives for debug purpose and prints only some command taking the # away. The actual program I want to control needs that # I cannot make without it.

0

There are 0 best solutions below