<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use Tie::IxHash;
tie %paramVal, "Tie::IxHash"; # keeps order of insertion in hash


$wgetCmd="/usr/bin/wget ";    # path of your systems wget -d -v -S 


$coordFile="./LAS.txt"; # path of your file of coordinates



# form values

$paramVal{"archive"}="WSA";
$paramVal{"database"}="UKIDSSDR11PLUS"; # database 
$paramVal{"programmeID"}="101"; # 101=LAS 
$paramVal{"band__1"}="Y";
$paramVal{"band__2"}="H";
$paramVal{"band__3"}="K";

$paramVal{"idPresent"}="noID";
$paramVal{"userX"}="1.0"; # size arcminutes
$paramVal{"email"}="";
$paramVal{"email1"}="";
$paramVal{"crossHair"}="n";
$paramVal{"mode"}="wget";


$numCoords=10000;  # number of coords in a loop CANNOT be &gt; 20000


#################

$fileExtension="tmp.wget";                # extension used to search output


print "File extension $fileExtension \n";


$boundary="--FILEUPLOAD";           # separator

$loopCount=0;

$i=0;

open (COORDS,"&lt;$coordFile");

$loop=0;


while (!eof(COORDS)) {
    $paramVal{"startID"}=$numCoords*$loop;
    $loop++;
    $uploadFile="upload_".$loop.".txt";
    $outFile="out_".$loop.".txt";
    print $uploadFile, "\n";
    open (UP,"&gt;$uploadFile");

    while (($param, $value) = each(%paramVal)){
        if ($param=~ /band__/) {
	    $param="band";
	}
	print UP "$boundary\n";
	print UP "Content-Disposition: form-data; name=\"$param\"\n\n";
	print UP "$value \n";
    }

    print UP "$boundary\n";
    print UP "Content-Disposition: form-data; name=\"fileName\"; filename=\"$uploadFile\" Content-Type: text/plain\n\n";

    $i=0;
    while ( $i &lt; $numCoords &amp;&amp; defined($line=&lt;COORDS&gt;)) {
	$i++;
	chomp($line);
#	print "$numCoords here \n";
	print UP $line,"\n";
    }


    
    print UP "\n$boundary--\n";
    close(UP);
    system ("$wgetCmd --keep-session-cookies --header=\"Content-Type: multipart/form-data;  boundary=FILEUPLOAD\" --post-file $uploadFile http://wsa.roe.ac.uk:8080/wsa/tmpMultiGetImage -O $outFile");


    open (OUT,"&lt;$outFile");
    $found=0;

    while (&lt;OUT&gt;){
	$record=$_;
	if ($found==0){
	    if ($record =~ /$fileExtension/){
		$endPos=index($record,$fileExtension);
		$strtPos=rindex(substr($record,0,$endPos),"http");
		$fileURL=substr($record,$strtPos,$endPos-$strtPos+length($fileExtension));
                print "$record \n";
		print "$endPos $strtPos downloading  $fileURL file\n";
                $dlFile= $loop."_wget.sh";
                $offset=($loop-1)*$numCoords;
		system ("$wgetCmd $fileURL -O $dlFile");
		$found=1;
	    }
	}
    }
close (OUT);
    print "Start sleep \n";
    sleep (5);
print "End sleep \n";
}

close (COORDS)

</pre></body></html>