Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Configuring static router

by zaki (Initiate)
on Aug 10, 2012 at 17:21 UTC ( [id://986783]=perlquestion: print w/replies, xml ) Need Help??

zaki has asked for the wisdom of the Perl Monks concerning the following question:

hi , i am new in perl and i am testing data plane behaviour of virtual router for this i wrote a simple code below which work well till second last line but in the last line where i am configuring router with static route it shows me error that syntax is wrong although the command is correct to configure static route.Can any body help me to tell how to configure static route in perl?
system(" vmm ping "); print" Enter the Router you want to connect with "; $router = <>; chomp ($router); $cmd = " ssh $router traceroute 10.0.0.128 > output1.txt"; system ($cmd); system( "ssh $router cli edit"); system ("set routing-options static route 10.0.0.128 next-hop 10.0.0.1 +10" );

Replies are listed 'Best First'.
Re: Configuring static router
by blue_cowdawg (Monsignor) on Aug 10, 2012 at 18:12 UTC

    Please consider reading "How (Not) To Ask A Question" before your next post. Especially the part about formatting. I'm having a real tough time reading your post.

    I'm at a loss for understanding what you mean by "virtual router" in your post. Is this some entity that exists only in software? Secondly, the "system" function may not be what you need to make things happen. Normally (and I've done this quite a bit) a router or other network element has a management interface of some sort either via console or some type of web interface.

    In the case of a serial console I'd recommend reading up on the CPAN modules Net::Telnet and/or Net::Telnet::Cisco. These modules do an excellent job of allowing one to programatically manipulate a router.

    In the case of a web interface I would look at LWP::UserAgent or WWW::Mechanize but I'll warn you that will be a bit more complicated.

    All system() does is send things to the command line from whatever shell you invoked the Perl script from. Unless you are running the Perl code on your router, which would surprise me, this isn't going to have the affect you're after.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Configuring static router
by hbm (Hermit) on Aug 10, 2012 at 17:29 UTC

    You are running that last command locally, not on the router...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://986783]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found