Hi
I'm trying to buield a perl script to do simple URL monitoring of URLs
I have 2 problems
1. Can't get imput parameters, only when its hardcoded into the script.
ex urlcheck.pl I can't get it to accept $url insteed og the hardcoded
2. The check tekst has to be very excact, I would like it to just check is the word is anywere in the output.
This works
but this doesn't - even this Msn in in the $string
I'm trying to buield a perl script to do simple URL monitoring of URLs
I have 2 problems
1. Can't get imput parameters, only when its hardcoded into the script.
ex urlcheck.pl I can't get it to accept $url insteed og the hardcoded
2. The check tekst has to be very excact, I would like it to just check is the word is anywere in the output.
This works
Code:
#! /usr/bin/perl
use HTTP::Request;
require LWP::UserAgent;
$url = @ARGV[0];
{ print "$url\n"; }
$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => '[URL unfurl="true"]http://www.msn.com');[/URL]
$response = $ua->request($request);
$string = "${%$response}{_content}\n";
if ($string =~ /MSN\s/)
{print "0\n";}
else
}
{ #print "ERROR\n";
print "1\n";
}
# { print "ERROR: $string\n"; }
but this doesn't - even this Msn in in the $string
Code:
#! /usr/bin/perl
use HTTP::Request;
require LWP::UserAgent;
$url = @ARGV[0];
{ print "$url\n"; }
$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => '[URL unfurl="true"]http://www.msn.com');[/URL]
$response = $ua->request($request);
$string = "${%$response}{_content}\n";
if ($string =~ /Msn\s/)
{print "0\n";}
else
}
{ #print "ERROR\n";
print "1\n";
}
# { print "ERROR: $string\n"; }