Subversion Repositories DevTools

Rev

Rev 5710 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : getDoc.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   :
10
#
11
# Usage:
12
#
13
# Version   Who      Date        Description
14
#
15
#......................................................................#
16
 
17
require 5.008_002;
18
use strict;
19
use warnings;
20
 
21
use Pod::Usage;
22
use Getopt::Long;
23
 
24
use JatsError;
25
use JatsSystem;
26
 
27
foreach my $docNum ( @ARGV )
28
{
29
    my $pageURL="http://bms:80/docregister/docLinkTo.asp?docnum=$docNum";
30
    print "--- $pageURL\n";
31
 
32
    #
33
    #   Get the document data
34
    #
35
    my $tmp_file = 'wget.data';
36
    unlink $tmp_file;
37
    System ('wget',
5710 dpurdie 38
            '--http-user=vix\\dpurdie',
392 dpurdie 39
            '--http-passwd=!stephaniec',
40
            "--output-document=$tmp_file",
41
            $pageURL );
42
 
43
    my $docURL;
44
    open ( my $fh, '<', $tmp_file ) || Error ("Cannot open file:$tmp_file: $!");
45
    while ( <$fh> )
46
    {
47
        print "$_\n";
48
        if ( m/self.location.href='(.*)'/ )
49
        {
50
            $docURL = $1;
51
            last;
52
        }
53
    }
54
    close $fh;
55
    unlink $tmp_file;
56
 
57
    Error ("Could not find doc ref: $docNum") unless $docURL;
58
    print "$docURL\n";
59
 
60
    #
61
    #   Extract file name
62
    #
63
    $docURL =~ m~.*/(.*)$~;
64
    my $fname = $1;
65
    $fname =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
66
    print "$fname\n";
67
 
68
    System ('wget',
5710 dpurdie 69
            '--http-user=vix\\dpurdie',
392 dpurdie 70
            '--http-passwd=!stephaniec',
71
            "--output-document=$fname",
72
            $docURL );
73
}
74
 
75