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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Is there a module to copy files from remote machines to my web server?

Replies are listed 'Best First'.
Re: Newbie needs help
by arturo (Vicar) on Mar 26, 2001 at 21:54 UTC

    The nearly-standard LWP family of modules is probably what you want, if you're trying to nab a web page. It can be as simple as:

    use LWP::Simple; my $code = getstore ('http://www.foo.com/stuff/gewgaws.html', '/my/fil +e/gewgaws.html'); print "Succeeded!\n" if $code == 200;

    If you're using some protocol other than HTTP, check out Net::FTP and the like.

    As for writing a client from scratch that will do the job, well ... you're probably better off telling those who get the client to get LWP, if you're distributing the client; and if it's that you don't administer the client machine, look into installing the LWP modules into directories you can write to. How to do this is covered in perlmodinstall.

    HTH

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      Thanks arturo. I think I did not communicate clearly as to my problem statement. I would like to get a file from the client's site. One they will point to when required. I have to then copy the file over to my web site. Access to my site will be through authentication. I will try and understand what you have said, and see if that helps.

        So, is your situation like this? You have a number of clients who need to be able to update files on your server which runs IIS? They will initiate the uploading process, and they need to be authenticated? (if so, how?)

        A reasonably standard way of handling this sort of thing would be to have your IIS machine run a CGI program that accepts file uploads; LWP is powerful enough to handle form submissions, including file uploads. If you search this site on "file uploads" you'll get more info than you want right now on how to write the CGI program. As for the client software, (the one that would use LWP) there's a book by Clinton Wong on writing Web Clients in Perl (published by O'Reilly and Associates that you might check out (if follow the link, there may even be a sample chapter).

        An alternate option is to handle the whole thing with FTP, with your IIS machine being the FTP server that accepts uploads; Net::FTP is the standard Perl way of writing an FTP client.

        HTH!

        Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: Newbie needs help
by bjelli (Pilgrim) on Mar 26, 2001 at 22:30 UTC

    If I understood you correctly you want to copy a file from a webclient to the webserver. You can not install scripts on the webclient.

    Here's one solution:

    1) create a webpage with a form

    The form contains a file-upload input tag, like so:

    <FORM ACTION="myupload.cgi" METHOD="POST" ENCTYPE="multipart/form-data"> Which file do you want to upload? <input type=file size=50 maxlength=100000 name="thefile"> [...other input tags...] </FORM>

    2) Now create a cgi-script

    This script handles the uploaded data. with my example form the cgi-script need to be called "myupload.cgi". use the module CGI to get the data:

    use CGI; $query = new CGI; $filename = $query->param('thefile'); while(<$filename>) { # do something with the data. }

    But don't just copy my code, read the man page of CGI!

    --
    Brigitte    'I never met a chocolate I didnt like'    Jellinek
    http://www.horus.com/~bjelli/         http://perlwelt.horus.at
      Thank you all for trying to help me. bjelli, your suggestion came close to what I have done (after I posted my problem here). I am cyrrently trying to get the server cgi script (reading cgi.pm), as I am getting some header errors. Thank you all for your help. You guys rock !!!
        got it. the use cgi statement needs ':standard' and I had to print standard headers. which corrected the errors. Now to try and find the relevant copy stuff.
Re: Newbie needs help
by little (Curate) on Mar 26, 2001 at 23:12 UTC
    You might read the docs for cgi.pm and especially look for something like file upload but don't miss Ovid's cgi-course then, cause file uploading might endanger your server. So go and read! :-) It will help to answer your questions.

    Have a nice day
    All decision is left to your taste