What I have been able to do, though it is a cheap hack and will probably have to be re-written if I want this to be a serious program, is taken your idea of using a while loop and somewhat modifying the server/client. This is the modified client, and it works, though like I said, I think it's pretty cheesy:
#!/usr/bin/perl
use IO::Socket;
# Make our connections
my $ns1 = new IO::Socket::INET (PeerAddr => 'ns1',
PeerPort => 1200,
Proto => 'tcp'
) or die "Couldn't create socket: $!\n"
+;
my $line;
my $count = 0;
my $domain = 'hello.com';
my $ipaddress = '192.168.0.1';
while ($line ne 'CAIO') {
if ($count == 0) {
print $ns1 "HELO\n";
$count++;
} elsif ($count == 1) {
print $ns1 "dom:$domain\n";
$count++;
} elsif ($count == 2) {
print $ns1 "ipaddr:$ipaddress\n";
$count++;
} elsif ($count == 3) {
print $ns1 "addzone\n";
$count++;
}
sleep(1);
chomp($line = <$ns1>);
print "$line\n";
}
close($ns1);
As you might have gathered, the server is a name server, and this program was created to add zones via sockets. It's irrelevant to me at this point whether or not BIND supports this natively - This is just a good way for me to practice using Sockets and TK, and make my boss happy while I write programs that will eventually end up being my replacement :)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|