Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Advice: Network code experiments

by geektron (Curate)
on Oct 03, 2000 at 05:17 UTC ( [id://35030]=perlquestion: print w/replies, xml ) Need Help??

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

I've recently been given some new assignments at work that hit on the weakest part of my Perl knowledge - IPC/ RPC type code. I'll be writing codeto communicate w/ routers, switches, etc. to copy configuration files, check device status, etc.

The good part - I get to add some new tools to my belt. I know that I'll be using a lot of IPC::Open3 for the rcp calls, but I'd like to come up with some ways to play with IPC::Open3 before I start writing production code. (I'd also be interested in hearing about other ways to do similar tasks.)

I'm at a bit of a loss to think of ways to test/experiment, though. I think I could use IPC::Open3 to communication with the webserver I have running here on my home box, but that's only one way. ( And, there are other modules better suited to the task.)

I'm almost out of my league with the new assignments, but how else am I going to learn how to do this stuff if I don't actually do it?

BTW - I've read perlipc dozens of times now, but it doesn't really sink in for me until I bang out the code and deal with all the headaches of actually writing functional code.

Replies are listed 'Best First'.
(jcwren) Re: Advice: Network code experiments
by jcwren (Prior) on Oct 03, 2000 at 05:27 UTC
    Well, as you no doubt realized, you can do the majority of experimenting one box, since the IP address determines if it's a local or remote socket. That helps a lot, if you don't happen to have more than one machine sitting around your house.

    I'd probably start by writing a simple client server application to play MP3s "remotely". You could setup the server to play the files, and use the client as a control panel type application.

    Another application would be to write your own mini-web server. It doesn't have to do everything Apache does, just look for a GET, and return a page. Maybe gets the output of 'ps -eax', and display it as a web page. Or something similiar for diskspace utilization. Yes, there's a complete Perl based webserver, but that's not the point. You *want* to reinvent this wheel.

    You could also write a chat program like 'talk' or 'write', but allow a secondary channel for sending/receiving files. Or better yet, if you need to learn Qt or GTK, write a two-player battleship program.

    There's all sorts of cool things you could do if you turn on the mindset of 'What can I do remotely that I can't now that I'd be paid to play, er, continue my education with?'

    --Chris

    P.S. if none of these interest you, I can probably find you something around my boat I wanted automated with remote connections. The pay sucks, tho...

    e-mail jcwren
      hmm. . . all sort of interesting. getting ouput of 'ps' sounds more like the direction of stuff i'd want to do.

      i was trying to avoid writing both the client and the server. but that would direction would probably give me the most mileage, esp. since I have a feeling things like IO::Socket would also be of use. . .

      and i have two boxes running here at home, so I can actually perform 'real' remote connections. i didn't even think of this one: i can build a simple wrapper for 'rcp' commands - just copy them from my workstation to my webserver/firewall box. i could 'automate' pushing files to my webserver.

      and i'm not enough of a nerd. i don't have any MP3s, so i couldn't build an MP3 server. :)

      I'd probably start by writing a simple client server application to play MP3s "remotely". You could setup the server to play the files, and use the client as a control panel type application.

      This is what I did for a "project" to learn perl. I know my program is far from perfect, but it's a good way to learn stuff. Right now mine is controlled by CGI, but you should be able to easily modify it for controlled by a socket. If you don't want to write one from scratch, feel free to use mine. Be cautioned though, it does have some bugs. jukebox.tar.gz

RE: Advice: Network code experiments
by extremely (Priest) on Oct 03, 2000 at 05:42 UTC
    For the device status, I'd recommend SNMP::Session and SNMP::Util as well as Net::SNMP . All good tinkertoys. Most major gear will have SNMP available and you might just consider doing your other machines by writing SNMPd stuff for them.

    --
    $you = new YOU;
    honk() if $you->love(perl)

      Thanks, but I use these all the time. It's the IPC/RPC end of it that I'm looking for help with.

        I guess I wan't clear either. I would avoid RPC unless you need to run arbitrary code on the far side. The examples you gave (code to communicate w/ routers, switches, etc. to copy configuration files, check device status, etc.) can be done without needing to send code to be executed or to request arbitrary execution.

        Set up a HTTPd or SNMPd that will answer requests sent to it with the answers that you want. 90% of what people want to do in RPC they can do with HTTP tools that they already know.

        --
        $you = new YOU;
        honk() if $you->love(perl)

RE: Advice: Network code experiments
by ybiC (Prior) on Oct 03, 2000 at 06:46 UTC
Re: Advice: Network code experiments
by c-era (Curate) on Oct 03, 2000 at 15:58 UTC
    I written many scripts for cisco routers and switches, and every time I have used Net::Telnet. It works great, I have a script that changes the passwords on all devices. Another script clears and then checks all the interfaces for errors. I also have a script that resores the configuration from a tftp server. And to top it all off I have a script that updates the IOS from a tftp server.

    P.S. I have over 200 cisco devices I take care of.

      I already have an idea about the modules that I can use ( or more correctly, I already have an idea about which modules I'll be using ).

      I was looking for, as jcwren enumerated, ways to 'play' with the modules to learn them. I'm looking for silly little throwaway examples that I can use as learning experiments.

      And for the task you're describing ( which is one of the projects I'll be doing ) I've already decided on IPC::Open3 ( and probably Expect.pm as well ). I will need to log the errors with updating configs. Logging those errors will be easier with IPC::Open3.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-12-14 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (70 votes). Check out past polls.