help: downloading online files with perl

Discussion in 'Perl' started by kk, Dec 24, 2006.

  1. kk

    kk Guest

    Hi,
    I am trying to write a script that downloads a file from a website everyday.
    Can I just use the copy command (i.e. use File::Copy)? Does it support URI?
    I wrote something like below, but it does not seem to work.

    use File::Copy;
    copy(www.abc.com\abc.pdf, "C:\myfolder\") or die "File cannot be copied.";

    Is there a better way to do this?

    Sorry, it seems like a very easy thing to do, but I am doing something
    wrong...

    Thank you
    kk, Dec 24, 2006
    #1
    1. Advertising

  2. Re: downloading online files with perl

    kk wrote:
    > I am trying to write a script that downloads a file from a website
    > everyday.


    Your Question is Asked Frequently:
    "How do I fetch an HTML file?"

    > Can I just use the copy command (i.e. use File::Copy)?


    No.

    > Does it support URI?


    Well, of course not. A URI can be anything, not just a simple file.

    > I wrote something like below, but it does not seem to
    > work.
    > use File::Copy;
    > copy(www.abc.com\abc.pdf, "C:\myfolder\") or die "File cannot be
    > copied.";
    > Is there a better way to do this?


    Yes. As explained in the FAQ.

    jue
    Jürgen Exner, Dec 25, 2006
    #2
    1. Advertising

  3. kk

    Verizon Guest

    Re: downloading online files with perl

    "kk" <> wrote in message
    news:458eef17$0$8961$...
    > Hi,
    > I am trying to write a script that downloads a file from a website
    > everyday. Can I just use the copy command (i.e. use File::Copy)? Does it
    > support URI? I wrote something like below, but it does not seem to work.
    >
    > use File::Copy;
    > copy(www.abc.com\abc.pdf, "C:\myfolder\") or die "File cannot be copied.";
    >
    > Is there a better way to do this?
    >
    > Sorry, it seems like a very easy thing to do, but I am doing something
    > wrong...
    >
    > Thank you
    >

    Have a look at LWP (lib-www-perl). You'll probably need to do an HTTP
    request, but it supports ftp, gopher and local file systems using this
    module. I haven't tried this with what you're trying to do so I don't have
    any examples, but I have used LWP to retrieve HTTP pages.

    Craig
    Verizon, Jan 10, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nani
    Replies:
    0
    Views:
    378
  2. chinni
    Replies:
    0
    Views:
    383
    chinni
    Nov 20, 2009
  3. chinni
    Replies:
    0
    Views:
    445
    chinni
    Nov 20, 2009
  4. chinni
    Replies:
    0
    Views:
    463
    chinni
    Nov 20, 2009
  5. chinni
    Replies:
    0
    Views:
    440
    chinni
    Nov 20, 2009
Loading...

Share This Page