[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Unix to Mac



A freind asks this question. Can anyone point him in the right direction
to do what he wants?


The following linux perl script enables users to
alter the mapping of a dynamic dns assignment.
Do you know how to make such programs
run under macperl? It seems to me,
the use of IFCONFIG will not be found on the mac....
Right?


#!/usr/bin/perl
######################################################
#
# Perl implementation of DYNDNS.COM's NamedControl Client.
#
# by Gunnar Hellekson <ghelleks@herne.drew.edu> 11/2/96
#
# based (heavily) on p.342 of the 1st Camel book
#
######################################################

($ip, $user, $pass, $domain) = @ARGV;

$AF_INET = 2;
$SOCK_STREAM = 1;

$SIG{'INT'} = 'dokill';

sub dokill {
   kill 9,$child if $child;
}

$sockaddr = "S n a4 x8";

(
   chop($ip = `/sbin/ifconfig ppp0 | /usr/bin/grep inet | /bin/cut -f2
-d:
| /bin/cut -c1-15`) &&
   $ip =~ s/\s+//g
) unless $ip;

$user = "username" unless $user;
$pass = "password" unless $pass;
$domain = "dyndns.com" unless $domain;

$info = pack("a20", $user) . pack("a20", $pass) . pack("a16", $ip) .
pack("a64", $domain);

($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname(50, 'tcp') unless $port =~
/^d+$/;
($name, $aliases, $type, $len, $thisaddr) = gethostbyname(chop($hostname
=
`/bin/hostname`));
($name, $aliases, $type, $len, $thataddr) = gethostbyname("dyndns.com");

$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, 50, $thataddr);

socket(S, $AF_INET, $SOCK_STREAM, $proto) || die $!;
bind(S, $this) || die $!;
connect(S,$that) || die $!;

select(S); $| = 1; select(STDOUT);

if ($child = fork) {
   print "Waiting for routing tables to update...\n";
   sleep 10;
   print S $info;
   sleep 3;
   do dokill();
}
else {
   while (<S>) {
      printf("%s", $_);
   }
   print;
}

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org