#!/usr/bin/perl -dw
#SYNOPSIS
#  B URL
#DESCRIPTION
#  This does a scan starting at the URL, and also gives the URL
#  as a "Base" URL, so the scan will be restricted to URLs below
#  the starting URL.

$Vdefault = 3;	# For testing, this is usually 2 or 3
$| = 1;
$exitstat = 0;
($P = $0) =~ s".*/"";
$V = $ENV{"V_$P"} || $ENV{"D_$P"} || $Vdefault;	# Verbose level.
print "$P: Started with V=$V.\n" if $V>0;

unless (defined $ENV{'V_abcbot'}) {
	print "$P: Set V_abcbot to $V.\n" if $V>1;
	$ENV{'V_abcbot'} = $V || $Vdefault;
}
for $url (@ARGV) {
	$cmd = "./abcbot";
	$url =~ s"[\r\s]$"";
	if (($hst,$uri,$fil) = ($url =~ m"^http://([^/]+)/(.*)/([^/]*)$")) {
		print "$P: hst='$hst' uri='$uri' fil='$fil'\n" if $V>1;
		$cmd .= " B:http://$hst/$uri/ $url $hst";
	}
	if ($hst) {
		$cmd .= ">log/$hst 2>&1 &";
		print "$P: cmd= \"$cmd\"\n" if $V>1;
		system $cmd;
	}
#	print "$P: Scan $h DONE.\n" if $V>1;
}

print "$P: Exit with status $exitstat.\n" if $V>1;
exit $exitstat;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
