我目前正在與USGS的EarthExplorer一起根據空間座標設置一些Landsat場景的批量下載。他們提供了一個非常好用的腳本,在https://earthexplorer.usgs.gov/inventory/example/json-download_data-pl這很好。我工作的集羣上,儘管在正確安裝的所有Perl模塊,當我運行該腳本,我得到以下的輸出:當使用perl和earthexplorer時格式錯誤的JSON字符串
Running Script...
Error: Error: malformed JSON string, neither array, object, number, string or
atom, at character offset 0 (before "LWP will support htt...") at ./dl.pl line 182
這似乎好奇。作爲解釋,該腳本啓動了與
#!/usr/bin/perl
#use strict;
use warnings;
use 5.010;
use JSON;
use Scalar::Util qw(looks_like_number reftype dualvar);
use LWP::UserAgent;
use Getopt::Long qw(GetOptions);
my ($username, $password);
$username = "myusername_filled_in";
$password = "mypassword_filled_in";
GetOptions(
'username=s' => \$username,
'password=s' => \$password,
) or die "Error retrieving Username and Password\n";
和問題的代碼位是
$res = $response->{_content};
$res = decode_json $res;
在Can't run Perl script on other computer繼非常有用的意見,我也做了以下內容:
在違規代碼區域更改了
$response->content
到$response->decoded_content(charset => 'none')
。ran
lwp-request https://google.com/
剛剛拉回完整的網頁 - 沒有錯誤。所以,這似乎工作。試圖通過插入
print $response->decoded_content(charset => 'none');
,然後扔了錯誤
LWP will support https URLs if the LWP::Protocol::https module is installed.
而且,確實看到一些調試,LWP ::協議:: HTTPS安裝。
我覺得我必須有一些簡單的東西,我很想念 - 就像我如何定義我的用戶名和密碼(只是$username = "myusername";
等,聲明變量後)或其他asinine。
有沒有其他人遇到過這個問題?
從下面的查詢添加輸出:
$ which cpan ; head -n 1 `which cpan` ; echo 'o conf' | cpan | grep -P 'make|mbuild' ; set | grep ^PERL ; which perl ; perl -le'use LWP::Protocol::https; print "ok";'
/share/pkg/perl/5.10.1/bin/cpan
#!/share/pkg/perl/5.10.1/bin/perl
make [/usr/bin/make]
make_arg []
make_install_arg []
make_install_make_command [/usr/bin/make]
makepl_arg []
mbuild_arg []
mbuild_install_arg []
mbuild_install_build_command [./Build]
mbuildpl_arg []
PERL5LIB=/home/jb92b/perl5/lib/perl5:/home/jb92b/perl5/lib/perl5:/home/jb92b/perl5/lib/perl5
PERL_LOCAL_LIB_ROOT=/home/jb92b/perl5:/home/jb92b/perl5:/home/jb92b/perl5
PERL_MB_OPT='--install_base "/home/jb92b/perl5"'
PERL_MM_OPT=INSTALL_BASE=/home/jb92b/perl5
/share/pkg/perl/5.10.1/bin/perl
ok
燦您將此Perl腳本的開頭添加到該問題中? – raina77ow
根據請求編輯。另請參閱https://earthexplorer.usgs.gov/inventory/example/json-download_data-pl – jebyrnes
請提供您的聲明的基礎:LWP: :Protocol :: https已安裝 – ikegami