naghaveer has asked for the wisdom of the Perl Monks concerning the following question:

$ENV{HTTP_proxy}=$proxy_url; my $ff = File::Fetch->new(uri =>"http://xxxxx.htm"); my $where = $ff->fetch(); my $file = $ff->file; my $error=$ff->error(); delete $ENV{HTTP_proxy}; $jira->attach_file_to_issue($src_issue,$file); print "url: $file attached to $src_issue key \n .................. +.....\n"; unlink $file;

I want to fetch and attach .htm file from remote system. I'm using File::Fetch cpan module. I'm not able to attach file. ERROR: Could not stat tmpfile 'C:/Users/jira123/Desktop/New folder/Linking_scr ipts/Fe24.htm-8584': No such file or directory at C:/strawberry/p erl/vendor/lib/LWP/UserAgent.pm line 922. I can attach all other types of files. But unable to attach .htm files. please help me how to attach .htm files?

Replies are listed 'Best First'.
Re: Unable to fetch and Attach .htm files
by Corion (Patriarch) on Jan 10, 2014 at 09:32 UTC
    $ff->file is not documented as the local name of the file. Maybe $ff->output_file works. Maybe review File::Fetch.

      I tried it is not working. It is not fetching file content itself. I can attach all other types of file format with same code.

        This works for me and you should be able to modify your script accordingly.

        #!/usr/bin/env perl use strict; use warnings; use File::Fetch; my $url = 'http://perldoc.perl.org/File/Fetch.html'; my $ff = File::Fetch->new( uri => $url ); my $where = $ff->fetch( to => '/tmp' ) or die $ff->error; my $file = $ff->output_file(); # name of local file print "Fetched $url and stored as $file.\n";
        [mmusgrove@dev2 ~]$ ./ff.pl Fetched http://perldoc.perl.org/File/Fetch.html and stored as Fetch.ht +ml [mmusgrove@dev2 ~]$ ls -al /tmp/Fetch.html -rw-rw-r-- 1 mmusgrove users 38348 Jun 23 2013 /tmp/Fetch.html

        Update: I even tested it on Windows with Strawberry Perl.

        #!/usr/bin/env perl use strict; use warnings; use File::Fetch; my $url = 'http://perldoc.perl.org/File/Fetch.html'; my $ff = File::Fetch->new( uri => $url ); my $where = $ff->fetch( to => 'C:/TEMP' ) or die $ff->error; my $file = $ff->output_file(); # name of local file print "Fetched $url and stored as $file.\n";
        C:\Users\mmusgrove\Desktop>perl ff.pl Fetched http://perldoc.perl.org/File/Fetch.html and stored as Fetch.ht +ml. C:\Users\mmusgrove\Desktop>dir C:\TEMP Volume in drive C has no label. Volume Serial Number is 48AA-B4E2 Directory of C:\TEMP 01/10/2014 11:32 AM <DIR> . 01/10/2014 11:32 AM <DIR> .. 06/23/2013 02:53 PM 38,348 Fetch.html 1 File(s) 38,348 bytes 2 Dir(s) 165,768,085,504 bytes free