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

Hi,

I'm still quite new to perl, so my form is a bit off, but I'm trying to write a script that will talk to a Foundry ServerIron load balancer. I'm trying to do this with IO:Socket:INET, and I'm running into some issues. Here's the test script I'm using to see if I can get the script and the load balancer talking:

use IO::Socket; <P> my $userpass=password; my $enapass=drowssap; + my @list=("$userpass", "ena", "$enapass", "show server virtual", "exit +", "exit"); + my $foundry = new IO::Socket::INET ("loadbalancer:23") or die "Couldn't connect to loadbalancer!!!: $@"; + foreach $item (@list){ print $foundry "$item\n"; my $response = <$foundry>; print $response; } + exit 1;

Cheesey, but I'll do nicer stuff once I know I can get this going. Anyway, when I run the script, my output is a line of garbage characters, then "User Access Verification", which is what I expect to see, then it sits until I break out of the script.

For right now at least, I just want it to connect to the lb on the telnet port, give it the access password, enable, give the admin password, "show server virtual," then log off. Any ideas?

Thanks!

Replies are listed 'Best First'.
Re: perl talking to a load balancer
by c-era (Curate) on Jan 26, 2001 at 02:16 UTC
    You need to use the telnet protocol. You opened the socket correctly, but you need to send more then just text to comunicate via telnet. You can write your own (and have it filled with bugs and recieve the wrath of merlyn), or you can use the Net::Telnet module (it has very few bugs and you will recieve merlyn's blessing).
Re: perl talking to a load balancer
by clintp (Curate) on Jan 26, 2001 at 02:59 UTC
    You have other options as well. Use Net::Telnet. Or, even though this is on port 23 I doubt it implements telnet fully.

    (beware of buffering problems as well. You might want to try a $foundry->autoflush(1) in there...)

    A better solution for these kinds of problems (conversations) is to use the Expect module. It's built for these kinds of things.