"expect" spawns telnet -- screen height

"expect" spawns telnet -- screen height

am 26.02.2005 14:53:30 von Jens Bretschneider

Hi,

I'm trying to login to a router using telnet and EXPECT, to backup the
router config.

When I'm connecting to the device via telnet, everything is ok, but when I'm
using a perl/expect-Script to connect, the router asks "Press any key to
continue", even before the login prompt.

*** via telnet commandline:

# telnet 1.2.3.4
Trying 1.2.3.4...
Connected to 1.2.3.4.
Escape character is '^]'.


One200

Username:


*** via script

# ./save-cpe.pl
Trying 1.2.3.4...
Connected to 1.2.3.4.
Escape character is '^]'.


One200

Press any key to continue (Q to quit)



This is the perl code I spawn telnet with:

$telnet = Expect->spawn('telnet', $ipaddr)
or error_exit(11, "....");

Looks like the router thinks the screen height is just a few lines?

Any ideas?

Thanks,
Jens

Re: "expect" spawns telnet -- screen height

am 26.02.2005 15:46:44 von Joe Smith

Jens Bretschneider wrote:

> I'm trying to login to a router using telnet and EXPECT, to backup the
> router config.

http://search.cpan.org/search?query=net+telnet+cisco

Re: "expect" spawns telnet -- screen height

am 26.02.2005 18:26:30 von Jens Bretschneider

>> I'm trying to login to a router using telnet and EXPECT, to backup the
>> router config.
>
> http://search.cpan.org/search?query=net+telnet+cisco

It's not a Cisco router...

My script is working properly with Cisco, Accelerated/Occam-Networks- and
Efficient-Networks-Devices, without any problems. It's just this
OneAccess-Router-Type which asks for a keystroke...

Re: "expect" spawns telnet -- screen height

am 26.02.2005 23:22:18 von Jens Bretschneider

> This is the perl code I spawn telnet with:
>
> $telnet = Expect->spawn('telnet', $ipaddr)
> or error_exit(11, "....");
>
> Looks like the router thinks the screen height is just a few lines?

OK, I've found out that the following code works ok when run from a bash
shell:

my $telnet = new Expect;
$telnet->raw_pty(1);
if (defined ($telnet->slave)) {
$telnet->slave->clone_winsize_from(\*STDIN);
}

$telnet->spawn('telnet', $ipaddr)
or error_exit(11, ".....");

Unfortunately, I'm running this script from a PHP Page, NOT from a bash
shell... perl teminates without any hint when reaching the line
"$telnet->slave->clone_winsize_from(\*STDIN);".

Any Idea how to set the winsize to e.g. 80x25 without cloning it or where to
clone it from when run from a PHP script?

Jens

Re: "expect" spawns telnet -- screen height

am 20.03.2006 20:52:57 von dpratlong

My solution, based on Jens script, is not very elegant, but it works
from crontab (for example) :

open TTY,"/dev/console" or die "not connected to a terminal\n";
$telnet->slave->clone_winsize_from(\*TTY);
close TTY;

Daniel


--
dpratlong
------------------------------------------------------------ ------------
dpratlong's Profile: http://techiegroups.com/member.php?userid=83
View this thread: http://www.techiegroups.com/showthread.php?t=48673

Re: "expect" spawns telnet -- screen height

am 18.04.2006 18:10:53 von google

dpratlong schrieb:

> My solution, based on Jens script, is not very elegant, but it works
> from crontab (for example) :

Cooool! Thanks a lot! It works without any problems.

--
Jens