how to open a shell from perl program? How to write in the shell?

how to open a shell from perl program? How to write in the shell?

am 29.08.2006 14:19:10 von _mario lat

Hallo,
I'd like to open a shell from a program written in perl.
I write a little program that connect to a router and do some commands.
I'd like to ope a shell and directly write in the shell:
"
telnet myCiscoRouter
password_of_cisco
show interface I_NEED
"

The question are two:


1)How to open it

I try to use:
exec ( "xterm -fn 8x13 -geom 120x35+100+200 -title $router_name -e
\"/usr/bin/telnet $router_name\" &");

it open the shell but stop the programs.

2)ho to write more lines in the shell
I try:
exec ( "xterm -fn 8x13 -geom 120x35+100+200 -title $router_name -e
\"/usr/bin/telnet $router_name\npassword_of_cisco\nsho interface....\n\" &");
but don't wors well.


Thank you in advance for the time you spend for help me
Mario.

Re: how to open a shell from perl program? How to write in the shell?

am 29.08.2006 16:14:12 von Joe Smith

mario.lat_ wrote:
> I'd like to open a shell from a program written in perl.
> I write a little program that connect to a router and do some commands.

You don't need a shell for that.

use Net::Telnet::Cisco;
my $session = Net::Telnet::Cisco->new(Host => '123.123.123.123');
$session->login('login', 'password');
my @output = $session->cmd('show version');
print @output;