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

Got another question. I need to tell a program called brutefir what to do with perl on the same system. I've been reading http://perldoc.perl.org/perlipc.html and frankly I don't get it. Can someone give me a sort of basic example that applies specifically to brutefir. Brutefir docs say it will accept cli through telnet, a local socket, a pipe, or a serial line. I'm assuming a pipe is the ideal why to communicate with it but please correct me if I'm wrong. I don't know much about pipes. The simplest command to test with is abort I'd say because it kills the program, pretty easy to see. I don't think I will need to return any data from brutefir but if it's simple enough I'm sure it might come in handy. Thanks in advance, Bronston

Replies are listed 'Best First'.
Re: Help with perl to cli pipe
by kschwab (Vicar) on Nov 19, 2013 at 02:57 UTC

    If you are most interested in getting it up and running quickly, without having to think much about the underlying details, telnet is probably the easiest route.

    I say that largely because of the Net::Telnet module. It understands the idea of a CLI, setting the expected prompt character (appears to be "> " in BruteFir), etc.

    Other than looking at BruteFir's docs for a few minutes, I don't have any experience with it. That said, this short example "should work", unless I missed something important.

    my $host="hostname.whatever.com"; use Net::Telnet (); $t = new Net::Telnet (Timeout => 10, Port => 3000, Prompt => '/> $/'); $t->open($host); @helptext = $t->cmd("help"); print @helptext;

    One caveat...I did find it a bit odd that the CLI configuration allowed you to configure a listen port, but not which ip addresses to listen on, so you can't restrict it to just localhost. I didn't see support for a password either. So it appears that once you turn it on, anyone can connect to it. You might want to use iptables to restrict access if you go this route.

      Shoot I forgot to mention I can't install modules on this system.
        If you can create a file, you can install a module locally, in your home directory.