Auto-dialing from Linux

Steve Willer (willer@interlog.com)
Tue, 17 Jun 1997 02:31:46 -0400


On Monday, June 16, 1997 10:47 PM, Seth D. Schoen
[SMTP:sigma@ishmael.nmh.northfield.ma.us] wrote:
> I'm currently using dialup at home and have problems using dial-on-demand
> (first, there's no such thing obvious to me for Linux 1.2.13, although
> I'm
> considering writing a very scaled-down Unix equivalent of DESGUI -- and
> second, other people are often using the phone line, so I can only use it
> at night).

This is the perl script that I've been using to wrap around deschall on
Linux. I should probably change the 'ifconfig' running with a check for the
existence of the ppp pid file, but I haven't had the chance yet. Make sure
that whatever user you run this as has access to ppp-on and ppp-off without
passwords or the like.

#!/usr/bin/perl

# startup deschall, attach pipe
$server = shift @ARGV;
$copies = shift @ARGV;

$_ = `ifconfig`;
if (/ppp/) {
open(DESCHALL, "/usr/local/bin/deschall $server $copies 2>/dev/null |");
}
else {
system("nslookup gold.interlog.com >/dev/null 2>/dev/null "); # NOTE
$launchafter = 1;
}

# retrieve output, look for an indication that we need a connection
if ($launchafter) {
$_ = "whatever";
}
else {
$_ = <DESCHALL>;
}
while ($_) {
if (! $launchafter) {
print $_;
}
if (/Program version:/ || /Elapsed time:/ || $launchafter) {
# initialize connection
$_ = `ifconfig`;
if (! /ppp/) { $dialup = 1; }

# wait for connection to open
if ($dialup) {
# NOTE: Enter whatever command you want that will initialize
# your PPP connection. I use dial-on-demand, so I don't need this.
system("/usr/sbin/ppp-on");
print "=== Waiting for connection\n";
$_ = `ifconfig`;
while (! /ppp/) {
sleep 3;
$_ = `ifconfig`;
}
sleep 2;
}
#if (!system("ping keymaster.verser.frii.com -c 4")) {
# print "=== KEYMASTER HAS DIED\n";
# die "Keymaster dead; giving up";
#}

if ($launchafter) {
open(DESCHALL, "deschall $server $copies 2>/dev/null |");
$launchafter = 0;
}

# wait for engine to grab a new key
$_ = <DESCHALL>;
while (! /complementary pairs of keys/ && $_) {
print "$_";
$_ = <DESCHALL>;
}
print $_;

# hangup
if ($dialup) {
sleep 2;
print "=== Disconnecting\n";
system("/usr/sbin/ppp-off >/dev/null 2>/dev/null"); # NOTE
}
}
$_ = <DESCHALL>;
}

----
Steve Willer, willer@interlog.com
"A computer scientist is someone who, when told to 'Go to Hell,'
sees the 'go to,' rather than the destination, as harmful."