in reply to Re^3: How to download or run exe file using rest client.
in thread How to download or run exe file using rest client.

Hi Thanos

Thanks for the reply, below code is working for me to get the exe file but while executing that file, I am facing "filename header error".

use strict; use LWP::Simple; my $url = "URL"; ##die "Couldn't get it!" unless defined $content; my $file = "BCM_console.exe"; my $code = getstore($url, "$file"); print "CODE : $code\n";
Are there any headers I need to pass here, how we can pass them.
Regards.

Replies are listed 'Best First'.
Re^5: How to download or run exe file using rest client.
by hippo (Archbishop) on Mar 20, 2019 at 13:21 UTC

    If I run your code as it stands, but with a valid URL as the value for $url it succeeds fine. Therefore the problem is specific to the URL you are actually using. Since you haven't said what that is, it will be hard to help you further.

    #!/usr/bin/perl use strict; use LWP::Simple; my $url = "https://www.perlmonks.org/?node_id=1231486;part=1;abspart=1 +;displaytype=displaycode"; ##die "Couldn't get it!" unless defined $content; my $file = "BCM_console.exe"; my $code = getstore($url, "$file"); print "CODE : $code\n";

      HI hippo, Thanks for the reply.

      My url looks like below my $url = "http://server_address:port/ws/1/console/webstart?full=true" +; #Above url fetches the exe file as expected but I am not able to run i +t, getting "missing filename header error".

      Regards

Re^5: How to download or run exe file using rest client.
by thanos1983 (Parson) on Mar 20, 2019 at 12:27 UTC

    Hello again Anonymous Monk,

    It seems the file you are downloading in not executable. On this case it is not related to Perl but you need to get a valid file.

    I would also suggest a few minor configurations to your script to reduce the possibility of an error:

    #!/usr/bin/perl use strict; use warnings; use LWP::Simple; my $url = "URL"; my $file = "BCM_console.exe"; my $code = getstore($url, "$file"); die "Error: $code on $url" unless is_success($code);

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re^5: How to download or run exe file using rest client.
by Anonymous Monk on Mar 20, 2019 at 11:44 UTC

    EXACT ERROR "missing filename header".

      What does running this show ?

      #!perl use strict; use warnings; use LWP::UserAgent(); printf "%s Perl %s LWP %s\n\n",$^O,$^V,$LWP::VERSION; my $url = 'URL'; my $ua = LWP::UserAgent->new; my $resp = $ua->head($url); print $resp->as_string;
      poj

        Hi Poj, Thanks for the reply.
        Result of the asked program

        MSWin32 Perl v5.14.2 LWP 6.03 400 URL must be absolute Content-Type: text/plain Client-Date: Wed, 20 Mar 2019 14:20:34 GMT Client-Warning: Internal response 400 URL must be absolute

        Regards.