Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WWWXXX .CMD, Wwwwxxx reemine, WWWXXX.VCBA, WWWXXX.VCBA, TheboL.wwwxxxxx, WWWXXXAPC , wwwxxn.xsss, wwwxxxapc, WWWXXX.VCBA, wwwxxx vba

Links

XODOX
Impressum

#1: "expect" spawns telnet -- screen height

Posted on 2005-02-26 14:53:30 by 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

Report this message

#2: Re: "expect" spawns telnet -- screen height

Posted on 2005-02-26 15:46:44 by 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

Report this message

#3: Re: "expect" spawns telnet -- screen height

Posted on 2005-02-26 18:26:30 by 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...

Report this message

#4: Re: "expect" spawns telnet -- screen height

Posted on 2005-02-26 23:22:18 by 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

Report this message

#5: Re: "expect" spawns telnet -- screen height

Posted on 2006-03-20 20:52:57 by 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

Report this message

#6: Re: "expect" spawns telnet -- screen height

Posted on 2006-04-18 18:10:53 by 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

Report this message