For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > August 2006 > how to open a shell from perl program? How to write in the shell?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to open a shell from perl program? How to write in the shell?
mario.lat_

2006-08-29, 7:57 am

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.


Joe Smith

2006-08-29, 6:57 pm

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;
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com