in reply to how to upload a file to a secured website?

Hi,
I'd do it with WWW::Mechanize. Use WWW::Mechanize::Shell to connect (after setting the proxy as http_proxy env. variable), authenticate and upload, then use script <filename> to generate a Perl script which does exactly what you did in the shell.
Then build your application around it.
Regards,
svenXY

Replies are listed 'Best First'.
Re^2: how to upload a file to a secured website?
by KarthikK (Sexton) on Oct 16, 2007 at 12:05 UTC
    Hello SvenXY, Thanks for your reply. is it possible for you to explain bit more in detail or do you have any sample code? i am a newbie to perl and I am still learning things everyday Also this i need to achive using a Perl script and not CGI. Thanks in advance regards Karthik
      Hi,
      as said, install the two modules mentined above. Then do
      perl -MWWW::Mechanize::Shell -eshell
      You will end up in that shell. Type help for help, then e.g. type connect http://bla.bla to connect to that URL.
      Make your way through the pages (it's a bit like using a text browser). Remember: help is at hand
      When you have what you wanted to do, type
      script myscript
      After quitting the shell (the Mechanize-Shell), you find a file called myscript in your directory that contains the code that will do exactly what you did in the shell. This page should help you.
      update: passing Apache Basic Auth. creditial with WWW::Mechanize? has some information on the auth part of your problem
      Regards,
      svenXY
        I would suggest that you should try simple LWP first and if you realize that the authentication is complex (more than just setting user and password in the standard brower user/password window) to use WWW::Mechanize. Your code should look like this: require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->proxy('https', 'ftp', 'http://proxy.sn.no:8001/'); $ua->credentials( 'servername:portnumber', 'realm-name', 'username' => 'password' ); Have a look at http://lwp.interglacial.com/ch11_03.htm. If you use Windows, then you may also have issues with the SSL module as it is not always included in the distribution.