RE: help with perl please?
Posted in 2008
Hello, FYI for the kind folks who were interested and tried to help me with my perl script. The timeout setting appears to work, but not for the reason I needed it. I followed some other workaround examples and the script is timing out now. Thanks much, Norma Jean The workaround: my $useragent = LWP::UserAgent->new( protocols_allowed => ["https"] ); my $request = POST( "https://xxxxx/xxxx.dll", $request_values ); eval { local $SIG{'ALRM'} = sub { die "Timed out" }; alarm(5); # timeout in 5 seconds #sleep 20; # test the timeout problem my $response = $useragent->request( $request ); alarm(0); ..... other commands to be done when timeout is not a problem.... }; if ($@ =~ /Timed out/) { print "Communication Timed Out.\\n"; }; From: informix-list-bounces@iiug.org [mailto:informix-list-bounces@iiug.org] On Behalf Of Norma Jean Sebastian Sent: Friday, December 19, 2008 12:51 PM To: informix-list@iiug.org Subject: help with perl please? Hello all, I know this isn't really the forum for this, but I am hoping some kind soul who knows perl can help me. I am very new to perl, actually so new that I am simply trying to hack a script I inherited. The script has statements as follows (url was changed): my $useragent = LWP::UserAgent->new( protocols_allowed => ["https"] ); my $request = POST( "https://xxxxx/xxxx.dll", $request_values ); my $response = $useragent->request( $request ); I have found that when there is an internet issue, it takes 3 minutes for the script to timeout. I found (google) this can be changed by setting a timeout value in the UserAgent. So I tried both of the following, but it's not making a difference, I still timeout in 3 minutes instead of 10 seconds: attempt #1: my $useragent = LWP::UserAgent->new( protocols_allowed => ["https"] ); $useragent->timeout(10); Attempt #2: my $useragent = LWP::UserAgent->new( protocols_allowed => ["https"], timeout => 10, ); I would be happy to send more of the script to someone, I am at my wits end... and I don't have many wits J Thanks for any help, Norma Jean