Solved

problem with use lwp

Posted on 2000-05-06
18
440 Views
Last Modified: 2010-03-05
evertime I try to access lwp in a script i get this message:

Can't locate LWP.pm in @INC (@INC contains: lib /usr/lib/perl5/i386-linux/5.00403 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl

I have a web hosting account with Netcom/Mindspring and they tell me the module 'should' be there. can anyone help me with this?
0
Comment
Question by:mercytom
  • 8
  • 5
  • 4
  • +1
18 Comments
 
LVL 8

Expert Comment

by:shlomoy
ID: 2785146
Seems like LWP wasn't installed (properly).
0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2785183
How do you call the LWP module ? Can you post the snippet of PERL code here ?
0
 

Author Comment

by:mercytom
ID: 2785227
of course,
with respect to the expert who posted it here..

#!/usr/bin/perl -d

use lib "lib";
require LWP;
require URI::URL;

use strict;
use CGI;

my($hdr,$server_response);
my($statement_URL)="http://www.yahoo.com";

$server_response=&browse($statement_URL,$hdr);  ##  Fire the URL

print "Content-type: text/html\n\n";

open(TMP,">/tmp/yahoo.html") || die $!;
print TMP $server_response;
close(TMP);
print $statement_URL," obtained!!<P>\n";
   
sub browse(){
  my($statement_URL,$hdr)=@_;
  my($content_type,$method);

  $content_type="application/x-www-form-urlencoded";
  $method="GET";

  my($headers)= new HTTP::Headers 
    'Content-Type'   =>  $content_type,
    'MIME-Version'   =>  '1.0',
    'Date'           =>  HTTP::Date::time2str(time),
    'Accept'         =>  'text/html';

  my($ua)= new LWP::UserAgent;

  $ua->agent("Mozilla/4.7 [en] (WinNT; U)"); # Define env variable - HTTP_USER_AGENT

  my($url)= new URI::URL($statement_URL);
  my($request)= new HTTP::Request($method, $url, $headers);

  my($response)= $ua->request($request);

  my($reply);

  if ($response->is_success){
    $reply=$response->content;
  }else{
    $reply=$response->error_as_HTML();
  }
  return $reply;
}

0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2785233
try

use LWP ;

instead of

require LWP;
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2785242
Good advice!
0
 

Author Comment

by:mercytom
ID: 2785410
Can't locate LWP.pm in @INC (@INC contains: lib /usr/lib/perl5/i386-linux/5.00403 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .)
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2792719
mercytom,

what is the full location of LWP.pm? (Eg /usr/local/lib/LWP.pm)
you can use the UNIX find command to get the location of LWP.pm

find  / -type f -name "LWP.pm" -print 2> /dev/null

NOTE: Since you would be searching the ENTIRE system, this search would be slow.

once you have the full path to LWP.pm, lets say /usr/local/lib

then change .....

use lib "lib";

TO...

use lib "/usr/local/lib";

Let me know how it goes.
0
 

Author Comment

by:mercytom
ID: 2795251
I called mindspring's tech support and they told me that they couldn't find the module (I have no command line privilige). The suggested that it was in /usr/bin/perl but I get basically the same message when I copy it in place of 'lib' as you suggessted.

Suppose it isn't installed on my server. Can I copy it to a directory on my site? How would I do that?
0
 

Author Comment

by:mercytom
ID: 2795254
The following script:
#!/usr/bin/perl -d

use lib "/usr/bin/perl";
use LWP;
require URI::URL;

use strict;
use CGI;

my($hdr,$server_response);
my($statement_URL)="http://www.yahoo.com";

$server_response=&browse($statement_URL,$hdr);  ##  Fire the URL

print "Content-type: text/html\n\n";

open(TMP,">/tmp/yahoo.html") || die $!;
print TMP $server_response;
close(TMP);
print $statement_URL," obtained!!<P>\n";
   
sub browse(){
  my($statement_URL,$hdr)=@_;
  my($content_type,$method);

  $content_type="application/x-www-form-urlencoded";
  $method="GET";

  my($headers)= new HTTP::Headers 
    'Content-Type'   =>  $content_type,
    'MIME-Version'   =>  '1.0',
    'Date'           =>  HTTP::Date::time2str(time),
    'Accept'         =>  'text/html';

  my($ua)= new LWP::UserAgent;

  $ua->agent("Mozilla/4.7 [en] (WinNT; U)"); # Define env variable - HTTP_USER_AGENT

  my($url)= new URI::URL($statement_URL);
  my($request)= new HTTP::Request($method, $url, $headers);

  my($response)= $ua->request($request);

  my($reply);

  if ($response->is_success){
    $reply=$response->content;
  }else{
    $reply=$response->error_as_HTML();
  }
  return $reply;
}
Yields this...

Loading DB routines from perl5db.pl version 1 Emacs support available. Enter h or `h h' for help. Can't locate LWP.pm in @INC (@INC contains: /usr/bin/perl /usr/lib/perl5/i386-linux/5.00403 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .) at /www/home/aboutpaperplus.com/cgi-bin/test2.pl line 4. BEGIN failed--compilation aborted at /www/home/aboutpaperplus.com/cgi-bin/test2.pl line 4. DB::fake::(/usr/lib/perl5/perl5db.pl:2084): 2084: "Debugged program terminated. Use `q' to quit or `R' to restart."; DB<1>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2795318
You can achieve the same functionality using IO::Sockets ,, which comes with the core perl ...
0
 

Author Comment

by:mercytom
ID: 2795414
I sort of understand that Chris, but isn't that functionality somewhat dwarfed by the elegance of lwp:, html, url and all the other enhancements to Perl?

More importently to me. I'd like to have the tech support for my ISP stop giving me the runaround by saying 'uh, yeah, i think it's there....' or 'Those modules should be there...'

So I'd truly like to understand the problem and take it to my ISP's upstairs tech support people.

0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2795439
ok Normally You should be able to install PERL modules in your local directory if you have TELNET access ..

Do you have telnet access ? if so upload all the required files to a 'temp' directory and I will give you step by step guidance for installing in local directory ...
0
 
LVL 8

Accepted Solution

by:
shlomoy earned 100 total points
ID: 2795440
use LWP::Simple qw/$ua/;
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2795445
I'd also add:
use LWP::UserAgent;
0
 

Author Comment

by:mercytom
ID: 2795641
Sorry chris. no telnet access. no command line access.

0
 

Author Comment

by:mercytom
ID: 2795653
shlomoy, if the compiler can't find lwp, what would make it find lwp::simple, or useragent?
0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2795698
If there is NO telnet access then there is NO WAY to install LWP in your LOCAL directory

SO I would advise either

1) change your Hosting provider (or)

2) use IO::Sockets Instead


0
 

Author Comment

by:mercytom
ID: 2798465
well, now knowing that, perhaps I can apply influence on the isp to install the modules.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now