##!/bin/sh # Source needed files exec /opt/freeware/bin/perl5.8.8 -x $0 $@ #!perl #line 9 use strict; use LWP; use URI::Escape; use ExtUtils::Installed; use LWP::Debug qw(+); # Credentials to access bluegroups my $bg_owner = 'xxx'; my $bg_password = 'xxx'; my $bluegroup='xxx'; my $cnum='xxx'; my $bgbrowser = LWP::UserAgent->new; $bgbrowser->agent('Mozilla/4.0'); $bgbrowser->credentials( 'bluepages.ibm.com:443', 'w3', "$bg_owner", "$bg_password"); my $response = $bgbrowser->get("https://bluepages.ibm.com/xxxxxx"); while ( my ($key,$value) = each %$response ) { print "$key => $value\n"; }
运行之后首次得到下面的错误:
_content => _rc => 501 _headers => HTTP::Headers=HASH(0x303cd26c) _msg => Protocol scheme 'https' is not supported _request => HTTP::Request=HASH(0x301fef18)
根据错误提示缺少必要的支持https的perl module Crypt::SSLeay,因此用cpan去安装,切忌如果出现Which SSL install path do you want to use? [/usr]的提示,一定要enter,不要输入yes。当安装到make test的时候发生了如下错误:
ssl OpenSSL 0.9.8k in /usr; # lib -L/usr/lib -lssl -lcrypto -lgcc # inc -I/usr/include # cc gcc -maix32 # Failed test 'HEAD https://rt.cpan.org/' # at t/02-live.t line 120. # HTTP status = 500 read failed: t/02-live.......NOK 4/4# This may not be the fault of the module, https://rt.cpan.org/ may be down # Looks like you failed 1 test of 4. t/02-live.......dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 4 Failed 1/4 tests, 75.00% okay (less 1 skipped test: 2 okay, 50.00%) Failed Test Stat Wstat Total Fail List of Failed ------------------------------------------------------------------------------- t/02-live.t 1 256 4 1 4
这个错误是告诉http 返回500内部错误,测试失败。接下来我如何做都没有找到方法,但是我可以肯定是perl module的问题,但是不确定具体是那个模块。所以最后找了一个workaround的方法,就是把我另外一台机器上完好的perl 环境打包拷贝到目前的环境上,然后脚本就正常工作了。哪位知道,也可以告诉我下!