- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:53 AM
06-20-2003 10:53 AM
Perl script
Requested page in $host, $date, $request variables. How do I capture
"http://www.portallink.com/finder.jhtml" in another variable $url in the same way.
Script:
#!/usr/bin/perl -w
$logfile = shift || &usage;
# forward declarations
my ($host, $date, $request);
# open the log
open(LOG, "<$logfile") or die "could not open $logfile\n";
while(
($host, $date, $request) =
$_ =~ m{
(.*?)\s # host name or IP
\[(.*?)\]\s # date
\"(.*?)\"\s # request method
}x;
print "$host $date $request \n";
}
Sample web log
216.177.64.101 - - [09/Apr/2003:00:00:41 -0400] "GET /logout.jhtml HTTP/1.0" 200 15758 "http://www.portallink.com/finder.jhtml" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" "ProfileCookie=demositelite,XYZ Company, Inc.,; JSESSIONID=OCZA0EYAAACSYCQFAKLSFEQKAUBJQI5G; anonauth=XYZuser%40XUMA123g; auth=demosite%40a3f7edcd509ca46e516f0249cbdc5f53; XYZdomain=www.portallink.com"
216.177.64.101 - - [09/Apr/2003:00:00:44 -0400] "GET /index.jhtml;jsessionid=OC0BPEIAAACS2CQFAKLSFEQKAUBJQI5G;jsessionid=OC0BPEIAAACS2CQFAKLSFEQKAUBJQI5G?LOGOUT=yes&DPSLogout=true&_requestid=42166 HTTP/1.0" 200 8194 "http://www.portallink.com/logout.jhtml" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" "ProfileCookie=demosite,XYZ Company, Inc.,; JSESSIONID=OC0BPEIAAACS2CQFAKLSFEQKAUBJQI5G; anonauth=XYZuser%40XUMA123g; auth=demosite%40a3f7edcd509ca46e516f0249cbdc5f53; XYZdomain=www.portallink.com"
216.177.64.101 - - [09/Apr/2003:00:00:45 -0400] "GET /index.jhtml HTTP/1.0" 200 19243 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" "ProfileCookie=demosite,XYZ Company, Inc.,; JSESSIONID=OC0BPEIAAACS2CQFAKLSFEQKAUBJQI5G; anonauth=XYZuser%40XUMA123g; auth=demosite%40a3f7edcd509ca46e516f0249cbdc5f53; XYZdomain=www.portallink.com"
Output from the script
./parse.pl sample
216.177.64.101 - - 09/Apr/2003:00:00:41 -0400 GET /logout.jhtml HTTP/1.0
216.177.64.101 - - 09/Apr/2003:00:00:44 -0400 GET /index.jhtml;jsessionid=OC0BPEIAAACS2CQFAKLSFEQKAUBJQI5G;jsessionid=OC0BPEIAAACS2CQFAKLSFEQKAUBJQI5G?LOGOUT=yes&DPSLogout=true&_requestid=42166 HTTP/1.0
216.177.64.101 - - 09/Apr/2003:00:00:45 -0400 GET /index.jhtml HTTP/1.0
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 11:10 AM
06-20-2003 11:10 AM
Re: Perl script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 11:12 AM
06-20-2003 11:12 AM
Re: Perl script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 11:13 AM
06-20-2003 11:13 AM
Re: Perl script
Something like \"http\:\/\/(.*?)\"\s
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 12:33 PM
06-20-2003 12:33 PM
Re: Perl script
Could you please send that script to rgoud@yahoo.com.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 05:28 PM
06-20-2003 05:28 PM
Re: Perl script
$input_file = $ARGV[0];
chomp($input_file);
$INFILE = new FileHandle;
$INFILE->open ($input_file, "r");
while ( !$INFILE->eof ) {
$line = $INFILE->getline;
if($line =~ /http\:\/\/www.portalink.com/) {
$name_flag=1;
while($name_flag && !$INFILE->eof) {
{
that is a start for a multiple seach inside a paragraph.
also if you want to search for diffrent lines
continue with
} elsif { ($line =~ /what ever/) {
bla bla bla
}
have fun.......
donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 05:36 PM
06-20-2003 05:36 PM
Re: Perl script
do something liek this.
if ($line =~ /http\:\/\/www.portalink/ {
do-something
} eslif ($line =~ /sessionid/) {
do-anotherthing
}
that ends the if statement, however you can have endless elsif's
the power of perl
peace