Solved

problem with use lwp

Posted on 2000-05-06
18
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

635 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