M
masmith27
Hello, I have made a very simple script in perl that uses LWP to visit
a few local webpages. The script has to execute without any user
interaction after the computer has finished booting. When the computer
boots up it starts the script and tries to get the first webpage. The
script then seems to hang after making the request, and setting the
timeout has no effect. The strange part is that if I hit any key a few
times the script then gets the webpage and continues normally.
LWP:
ebug gives the following:
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking 127.0.0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking .0.0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking 0.0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking .0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking 0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking .1 for cookies
LWP::UserAgent::send_request: GET https://127.0.0.1:2381/webpage.php
LWP::UserAgent::need_proxy: Not proxied
LWP:
rotocol::http::request: ()
and that's where it stops unless I hit a key or two on the keyboard.
This makes me think that for some reason perl is waiting for something
from stdin but there is nothing I can see that would make this the
case. The script works fine after hitting a few keys or after logging
into the system and issuing a command to run the script, but I need it
to run automatically using init.d. Is there a fix for something like
this? Or something I should check? I'm running out of ideas. The
relevant portion of the code is given below.
#!/usr/bin/perl -w
use LWP;
use HTTP::Cookies;
my $browser = LWP::UserAgent->new;
$browser->timeout("15");
$browser->cookie_jar( HTTP::Cookies->new('file' => '/tmp/cookies.lwp',
'autosave' => 1,
));
push @{ $browser->requests_redirectable }, 'POST';
$url = 'https://127.0.0.1:2381/webpage.php
$response = $browser->get($url);
die "Can't get $url -- ", $response->status_line unless
$response->is_success;
a few local webpages. The script has to execute without any user
interaction after the computer has finished booting. When the computer
boots up it starts the script and tries to get the first webpage. The
script then seems to hang after making the request, and setting the
timeout has no effect. The strange part is that if I hit any key a few
times the script then gets the webpage and continues normally.
LWP:
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking 127.0.0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking .0.0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking 0.0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking .0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking 0.1 for cookies
HTTP::Cookies::add_cookie_header: Checking .1 for cookies
LWP::UserAgent::send_request: GET https://127.0.0.1:2381/webpage.php
LWP::UserAgent::need_proxy: Not proxied
LWP:
and that's where it stops unless I hit a key or two on the keyboard.
This makes me think that for some reason perl is waiting for something
from stdin but there is nothing I can see that would make this the
case. The script works fine after hitting a few keys or after logging
into the system and issuing a command to run the script, but I need it
to run automatically using init.d. Is there a fix for something like
this? Or something I should check? I'm running out of ideas. The
relevant portion of the code is given below.
#!/usr/bin/perl -w
use LWP;
use HTTP::Cookies;
my $browser = LWP::UserAgent->new;
$browser->timeout("15");
$browser->cookie_jar( HTTP::Cookies->new('file' => '/tmp/cookies.lwp',
'autosave' => 1,
));
push @{ $browser->requests_redirectable }, 'POST';
$url = 'https://127.0.0.1:2381/webpage.php
$response = $browser->get($url);
die "Can't get $url -- ", $response->status_line unless
$response->is_success;