Malformed JSON string when using perl and earthexplorer -


i'm working usgs's earthexplorer setup batch downloads of landsat scenes based on spatial coordinates. provide wonderful handy script @ https://earthexplorer.usgs.gov/inventory/example/json-download_data-pl great. i'm working on cluster, , despite installing perl modules properly, when run script following output:

running script...   error: error: malformed json string, neither array, object, number, string or  atom, @ character offset 0 (before "lwp support htt...") @ ./dl.pl line 182 

this seems curious. way of explanation, script starts out with

#!/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);  ($username, $password); $username = "myusername_filled_in"; $password = "mypassword_filled_in";  getoptions(     'username=s' => \$username,     'password=s' => \$password, ) or die "error retrieving username , password\n"; 

and offending bit of code is

    $res = $response->{_content};     $res = decode_json $res; 

following useful advice in can't run perl script on other computer have done following:

  1. changed $response->content $response->decoded_content( charset => 'none') in offending area of code.

  2. ran lwp-request https://google.com/ pulled full webpage - no error. so, seems working.

  3. tried see debug inserting print $response->decoded_content( charset => 'none'); threw error

lwp support https urls if lwp::protocol::https module installed.

and, indeed, lwp::protocol::https installed.

i feel there must simple i'm missing - how defined username , password (just $username = "myusername"; etc., after variables declared) or else asinine.

has else run this?


to add output query below:

$ cpan ; head -n 1 `which cpan` ; echo 'o conf' | cpan | grep -p 'make|mbuild' ; set | grep ^perl ; 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 

your code doesn't check errors. should have like

$response->is_success()    or die("can't fetch x: ".$response->status_line()); 

the problem encountering lwp::protocol::https isn't installed.

you claim is, perl authoritative here :) wasn't installed perl, installed non-standard directory without tell perl there, or there's permission issue.

in case, script uses /usr/bin/perl, installed module using/for /share/pkg/perl/5.10.1/bin/perl. need switch perl script uses, or need install module using/for /usr/bin/perl.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -