?
Solved

determine web server type with HEAD

Posted on 2003-02-25
3
Medium Priority
?
146 Views
Last Modified: 2009-12-16
this is probably a stupid question but here goes:

i know how to do this:

C:\>/perl/bin/head www.website.com

200 OK
Cache-Control: private
Connection: Close
Date: Wed, 26 Feb 2003 01:51:29 GMT
Server: SErver Type here/2.0
Content-Length: 2824
Content-Type: text/html
Client-Date: Wed, 26 Feb 2003 01:51:24 GMT
Client-Response-Num: 1
Set-Cookie: PREF=ID=7804376706b65122:TM=1046224289:LM=1046224289:S=bjrD1brYqRTv
Y7h; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.website.com

but i want to do this in my program and get the same result:

    use LWP:Simple;

    (@stuff) = head($url);

i end up with a very empty array...iam obviously doing something wrong, and i cant find any good documentation on the HEAD method.

any help would be great.....thanx in adv
0
Comment
Question by:real1971
[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
3 Comments
 
LVL 10

Accepted Solution

by:
rj2 earned 400 total points
ID: 8022580
Code below works on my computer. Try to reinstall LWP if it don't work on yours.
http://search.cpan.org/author/GAAS/libwww-perl-5.69/

#!/usr/bin/perl
use LWP::Simple;
my ($content_type, $document_length, $modified_time, $expires, $server) = head("http://www.experts-exchange.com");
print "Server is $server\n";
0
 
LVL 48

Expert Comment

by:Tintin
ID: 8022591
As it says in the LWP::Simple doco

head($url)

Get document headers. Returns the following 5 values if successful: ($content_type, $document_length, $modified_time, $expires, $server)
Returns an empty list if it fails. In scalar context returns TRUE if successful

You have an empty list, so the head has failed.

0
 

Author Comment

by:real1971
ID: 8022637
thanx much for the help.......

i was trying to do the head($url) without the "http://"....that was the fix..thanx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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 …
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
Suggested Courses

777 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