radical hacks UPS Shipping Algorithm Etal Soames let me know that UPS was offering a way to calculate SHIPPING costs WITHIN a script according to the following instructions

Using the UPS Internet Tools Quick Cost Calculator
Datastream API You can link your company's World Wide
Web page directly to the UPS Quick Cost Calculator
using embedded CGI programming.

Required Parameters

* "accept_UPS_license_agreement=yes"
* "10_action=3 or 4"

Specifies level of service detail:

3       Price a single product.
4       Shop entire UPS product range, starting with
        the selected product.

* "13_product=UPS Product Code"

This parameter defines the type of UPS shipping.
The following table lists the UPS services with
the UPS product code for this application.

UPS Service             UPS Product Code
Next Day Air Early AM   1DM
Next Day Air            1DA
Next Day Air Saver      1DP
2nd Day Air AM          2DM
2nd Day Air             2DA
3 Day Select            3DS
Ground                  GND
Canada Standard         STD
Worldwide Express       XPR
Worldwide Express Plus  XDM
Worldwide Expedited     XPD

*  "14_origCountry= Origin Country"

Specifies origin country (US for United States or
PR for Puerto Rico).

* "15_origPostal= Ship from Postal Code"

The five digit postal code for the shipment origin.

* "19_destPostal= Ship to Postal Code "

The one to six alphanumeric-character postal code
of the destination country, if the destination country
uses postal codes.

* "22_destCountry= Ship to Country Code"

The country code of the shipment destination. For a
complete list of country codes, see Country Codes on
page 30.

* "23_weight= weight of package"

The weight of the package. If Shipment is a UPS
letter, no weight is needed.

* "47_rate_chart=Regular Daily Pickup, On Call Air,
One Time Pickup, Letter

Center, Customer Counter"
Rates vary depending on package origin and destination
address.

* "48_container=00, 01, 03, 21, 24, or 25"

00      Your Packaging
01      UPS Letter Envelope UPS Tube
21      UPS Express Box
22      UPS Worldwide 25KG Box
23      UPS Worldwide 10KG Box

Container allows the type of shipping container to be
specified.

* "49_residential=1 or 0"

1       Residential
0       Commercial
This option allows shipment to be designated as a
residential or commercial delivery.

Optional Parameters

* "20_destCity=Destination City"

Customer enters the destination city.

* "24_value=$$$"

Every package you send by UPS is automatically protected
against loss or damage up to $100. For packages having
a greater value, you can obtain additional coverage at
$.35 for each additional $100 or fraction thereof.
The maximum value or declared value per package is
$50,000 and the maximum carrier liability per package is
$50,000.

*  "25_length=inches"

Length of package.

* "26_width=inches"

Width of package.

* "27_height=inches"

Width of package.

* "29_oversized=1 or 0"

1       Oversized package
0       Not an oversized package

If a UPS GroundTrac(r) , UPS Ground Service or UPS
Standard Service package weighs less than 30 pounds
and exceeds 84 inches in combined length and
girth, the rate will be determined as if the package
weighed 30 pounds.

Additional Information
* Maximum single package weight: 150 pounds
* Maximum length: 108 inches
* Maximum size: 130 inches in length and girth combined
* "30_cod = 1 or 0"

1       C.O.D. package
0       Not a C.O.D. package

For your convenience, UPS offers Collect on Delivery
or C.O.D. Service for domestic shipments. Upon delivery,
UPS collects the amount shown on the C.O.D. tag attached
to the package and sends that amount to the shipper.
There is a charge of $4.75 for each C.O.D. received for
collection.

Restrictions

* UPS does not provide Call Tag service for UPS Next Day
Air Early A.M., UPS Next Day Air, UPS 2nd Day Air, UPS 3
Day Select, or UPS GroundTrac(r). You cannot use Call Tag
service to pick up Hazardous Materials / Dangerous Goods
including all "Other Regulated Materials" (ORM).

* "33_hazard= 1 or 0"
1       Hazardous material package
0       Non-hazardous material package

UPS accepts selected hazardous materials in all UPS
services for shipments to U.S. destinations. It is the
shipper's responsibility to determine if a package is a
hazardous material. Refer to the UPS Guide for Shipping
Ground and Air Hazardous Materials to determine the
acceptability of the material, required packaging, and
proper paperwork. [Contact us at 1-800-PICK-UPS for
a copy of this guide.]

* "34_handling= 1 or 0"
1       Package requires additional handling.
0       Package does not require additional handling.

UPS applies an Additional Handling Charge of $2.00
when you ship any of the following:

* Any article that is not fully encased in an outside
  shipping container
* Any article that is encased in an outside shipping
  container made of metal or wood
* Cans or pails that are not fully encased in a shipping
  container made of corrugated cardboard
* Any package that exceeds 60 inches in length
* "35_calltag= 0, 1, or 2"

0       No Call Tag
1       Basic Call Tag service
2       Electronic Call Tag service

UPS Call Tag service provides pick-up and prompt return
of merchandise previously delivered by us from anywhere
in the 48 contiguous states. When you issue a Call Tag, a
UPS driver picks up the merchandise at your customer's site
and applies a shipping label to the package. Then, it is
returned to your location via UPS Ground service. You will
be billed the shipping charges, as well as an additional
charge of $3.00 for each Call Tag. You may transmit your
Call Tags electronically. Call 1-800-PICK-UPS
(1-800-742-5877) for details.

* "37_saturdaydelivery = 1 or 0"
1       Saturday Delivery
0       No Saturday Delivery

UPS provides Saturday Delivery of UPS Next Day Air
shipments to all points that receive Monday through
Friday Next Day Air delivery by 10:30 a.m. or noon. UPS
also provides Saturday Delivery of UPS Next Day Air Early
A.M. shipments to all points that receive Monday through
Friday Early A.M. delivery by 8:00 a.m. or 8:30 a.m.
Saturday Delivery comes with all the features you
expect from UPS Next Day Air and Next Day Air Early A.M.
services, including electronic tracking of packages
and guaranteed on-time delivery or your money back.

* "38_saturdaypickup=1 or 0"
1       Saturday Pickup
0       No Saturday Pickup

UPS offers Saturday Pickup for UPS Next Day Air Early
A.M., UPS Next Day Air and UPS 2nd Day Air from most
locations in the United States for delivery to every
address in the United States. These shipments receive
the same time commitments for delivery as shipments
picked up on Friday.

* "39_response=0, 1, 2, 3, or 4"
0       None
1       Basic
2       Signature Required
3       Alternate Return Address
4       All Available Information

Delivery Confirmation Service provides automatic proof
of delivery for packages specifically designated by you.
Each confirmation response includes the date of delivery
and either the name of the receiver or the disposition
of the package. If the delivery is a returned item, the
response indicates the reason for the return. Both
Delivery Confirmation and Delivery Confirmation with
a signature are available. We consolidate all responses
and provide them to you each week in printed or electronic
format.

* "43_vcd= 1 or 0"
1       Verbal confirmation of delivery
0       No verbal confirmation of delivery

This parameter is used to request a Verbal Confirmation
of Delivery.

* "44_FirstShipNotify="0, 1, or 2"
0       None
1       Domestic
2       International

First Ship Notification enables the shipper to designate
notification to a business partner (consignee and/or
third party) that a package is scheduled
to be delivered at a specific address and/or date.

* "45_SecondShipNotify=0, 1, or 2"
0       None
1       Domestic
2       International

Second Ship Notification enables the shipper to designate
notification to an optional second business partner
(consignee and/or third party) that a package is scheduled
to be delivered at a specific address and/or date. This
parameter is used to request a Verbal Confirmation of
Delivery.

Sending Information

The following is an example of a CGI script to integrate
basic UPS package rating capabilities into your system.
This request asks for rating a simple request only sending
the required information. If a more detailed package
rating request is needed simply add the preceding
information into the $workString.

NOTE: The approach used in the example below is to
open a communication socket, submit a datastream,
and receive a datastream.  The total charge can
then be extracted from the received string through
further programming. The example is written in PERL
5.000 and is specific to UPS internal systems
configurations.  Any programming language can be
used.  Communication parameters will need to be changed
based on your system configuration.  UPS
can not support cgi debugging or communication
configuration problems.

Code Snippet for sockets:
$AF_INET = 2;
$SOCK_STREAM = 2;
$sockaddr = "S n a4 x8";
$port = 80;
$them = "www.ups.com";
$function = "GET";      #Type of HTTP
$workFile = "/using/services/rave/qcostcgi.cgi";
$versionInfo = "HTTP/1.0\n\n";
$workString = "?";
$workString .= "accept_UPS_license_agreement=yes";
$workString .= "&";
$workString .= "10_action=$upsAction";
$workString .= "&";
$workString .= "13_product=$upsProduct";
$workString .= "&";
$workString .= "15_origPostal=$OriginPostalCode";
$workString .= "&";
$workString .= "19_destPostal=$DestZipCode";
$workString .= "&";
$workString .= "23_weight=$PackageWeight";
$request = "$function $workFile$workString $versionInfo";
#
# Initialize communications to the server
#
if (!&InitCommunications()) # This is a function
                            # to establish a socket
                            # connection
{
  # send request to server
  #
  print S "$request\n";
  #
  # retrieve answer sent back from the server
  #
  $resultlist = '';
  while (<S>)
  {
    $resultlist .=$_;
  }
  close(S);
}
#
# Initialize Inter-process communications
#
sub InitCommunications
{
    $errmsg = "";
    #
    # get info for socket open
    #
    ($name, $aliases,$proto) = getprotobyname('tcp');
    ($name, $aliases,$port) = getservbyport($port,'tcp')
            unless $port =~/^\d+$/;

    ($tname, $aliases,$type, $len, $thisaddr) =
        gethostbyname($hostname);
    ($name, $aliases,$type, $len,$thataddr) =
        gethostbyname($them);

    #
    # pack information into structure for socket open
    #
    $this = pack($sockaddr, $AF_INET, 0, $thisaddr);
    $that = pack($sockaddr, $AF_INET, $port, $thataddr);
    #
    # Create the socket filehandle
    #
    eval
    {
        alarm($connect_timeout);
        if (socket(S, $AF_INET, $SOCK_STREAM, $proto) < 0)
        {
          $raveServer = 0;
           return 0;
        }
        #
        # disable buffering, flush after each write/print
        #
        select(S);
        $| = 1;
        select(STDOUT);
        if (bind(S, $this) < 0)
        {
           $raveServer = 0;
        return 0;
        }
        if (!connect(S, $that))
        {
           $raveServer = 0;
        return 0;
        }
        alarm(0);
    };
return $raveServer;
}

Receiving Rating Information

Rating information is returned in newline terminated
strings, with each piece of information separated by a
percent sign, as follows:

* 3%$product%$orig_postal%$orig_country
%$dest_postal%$dest_country%$zone
%$weight%$productchrg%$accs_surcharge%$totalchrg%$time%$\n

Rating information for a single product, specified by
$product.

$product        UPS product code
$orig_postal    Shipment origin postal code
$orig_country   Shipment origin country code
$dest_postal    Shipment destination postal code
$dest_country   Shipment destination country code
$zone   UPS zone identifier
$weight Package weight (empty if package is UPS Letter)
$productchrg    Charge for base service without
                additional charges
$accs_surcharge Charge for accessories and surcharges
$totalchrg      Total charge for shipping package
$time   Commit time (-1 if no commit time, EOD if
        end-of-day commit)

* 4%$product%$orig_postal%$orig_country%$dest_postal
%$dest_country%$zone%$weight%$productchrg%$accs_surcharge
%$totalchrg%$time%$\n

Rating information for all UPS products, starting with
specified product. Information as above for each UPS
procuct rated.

* 5%$errmsg%$errorCode%\n or 5%$errmsg%\n
Error message if package could not be rated. No rating
information follows.
$errmsg Error message
$errorCode      Error code
* 6%$message%[followed by 3 or 4, as above]
Warning message if UPS product, specified by $product,
might not be valid for this particular shipment. Rating
information follows immediately.
$message        Warning message