RE: [Hampshire] Possibly daft Perl/DOS question

Top Page

Reply to this message
Author: Bond, Peter
Date:  
To: adam.trickett, Hampshire LUG Discussion List
CC: 
Subject: RE: [Hampshire] Possibly daft Perl/DOS question
Adam wrote:
> Have you tried cURL from the Windows and the Linux box?


Nope; I've just started reading about it.

> I think Perl does the right thing, what does your script look
> like and what errors do you
> get back?


That's what I'd have assumed. The script stalls waiting for an ack from the server - and the server believes it is 55 chars short each time. Adding in the $CRLF on the sockets doesn't seem to have changed things, unfortunately.

You may reasonably derive from the script that I don't get to do much Perl...

Thanks!

Peter

------

#!/usr/bin/perl

# Perl-base upload/download script
#
# For a given list of files, attempt to upload each in turn to the encoder.
# Wait, then download the alarm file & store it.
# Repeat for as many iterations required.
#
# NB - no error checking in this version.
#

use HTTP::Request::Common;
use LWP::UserAgent;

use Socket qw(:DEFAULT :crlf);

# Modify as needed:

@upload_list = (
                "Test_001.xml",
                "Test_002.xml",
                "Test_003.xml",
                "Test_004.xml"
                );


$target_ip = "172.17.115.20";
$dest_path = "/tcf";
#

$alarm_file = "tcf";

$upload_delay = 3;
$iterations = 2;

###

print "HTTP Upload/download test\n";
$ua = LWP::UserAgent->new;

foreach $xml_file (@upload_list)
{
        print "$xml_file:\n";


        for $i (1 .. $iterations)
        {
                print "Iteration $i of $iterations\n";
                print "Upload $xml_file\n";
                $/ = $CRLF;
                $res = $ua->request(POST "http://$target_ip/" . "$dest_path",
                                Content_Type => 'multipart/form-data',
                                Content =>
                                [
                                        cgi => 'dcp',
                                        method => 'set',
                                        path => '/',
                                        localfile => ["$xml_file"]
                                ]);


                if ($res->is_success)
                {
                     print "ok\n";
                }
                else
                {
                     print $res->status_line, "\n";
                }


                print "Done.\n";


                sleep($upload_delay);


                $download_file = "$xml_file" . "_" . "$i";


                print "Download $download_file from $alarm_file\n";
                $downloaded_file = $ua->request(GET "http://$target_ip/$alarm_file",
                                        cgi => 'dcp',
                                        method => 'errors');


                # Write downloaded file out
                open ($outfile, $download_file);
                print ($outfile, $downloaded_file);
                close ($outfile);
        }
}


**********************************************************************

This email, its content and any attachments is PRIVATE AND
CONFIDENTIAL to TANDBERG Television, Part of the Ericsson Group.
If received in error please notify the sender and destroy the original
message and attachments.

www.tandbergtv.com
**********************************************************************