SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old October 10th, 2000, 09:34 PM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
Can someone offer some help with this script? It uses DBI to pull URLs from the "url" column of a mysql table. LWP then checks the validity of the URLs. The outcome of the link check is then reflected by an update to the "valid" column. This script worked great for me when I had a few hundred rows in my table. There are now over 7000. After about 900 rows the script just stops executing without any errors.

What causes the script to suddenly stop before checking every row?

Thanks!
Ryan McKillen

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
#!/usr/bin/perl

use LWP::UserAgent;
use DBI;

$db_database = "filedb";
$db_uid = "root";
$db_pwd = "pass";
($ua = LWP::UserAgent->new)->timeout(20); #actually set timeout


$dbh = DBI->connect ("DBI:mysql:$db_database".$mysqlsock, $db_uid, $db_pwd) or die("could not connect to dbn");
$sth = $dbh->prepare("SELECT url FROM files");
$sth -> execute();
$numrows = $sth->rows;

print "nn";
while (my $url = $sth->fetchrow_array) {
if(($ua->request(HTTP::Request->new('HEAD', $url)))->is_success()) {
$validity = "link works";
$valid_update = $dbh->do("UPDATE files SET valid = 1 WHERE url = '$url'");
}
else {
$validity = "link sucks";
$valid_update = $dbh->do("UPDATE files SET valid = valid + 1 WHERE url = '$url'");
}
print "$validityn$urlnn";
}
$sth->finish;
[/code]

[This message has been edited by scream (edited October 10, 2000).]

Reply With Quote
  #2  
Old October 11th, 2000, 02:31 AM
chrisdice4 chrisdice4 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Cape Town, WP, South Africa
Posts: 39 chrisdice4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
It might be you syntax in this line

$dbh = DBI->connect ("DBI:mysql:$db_database".$mysqlsock, $db_uid, $db_pwd) or die("could not connect to dbn");

try with qoutes around your password and username.

("DBI:mysql:$db_database"."$mysqlsock", "$db_uid, $db_pwd") or use single quotes if this does not work

Reply With Quote
  #3  
Old October 11th, 2000, 03:00 AM
MeijdenB MeijdenB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: Alkmaar, The Netherlands
Posts: 123 MeijdenB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>try with qoutes around your password and username.[/quote]

That won't work, because Perl won't understand the variables anymore then.

Reply With Quote
  #4  
Old October 11th, 2000, 06:00 AM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
If it was a little syntax issue involving quotes, perl would generate an error and not work in the first place. That couldn't have anything to with the script just stopping in the middle of its execution.

This is discouraging! Can anyone else offer me some help?

Reply With Quote
  #5  
Old October 11th, 2000, 04:58 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Run it from command line and send the output to whatever file.

You may as well changing the timeout value from 20 to something higher.

Reply With Quote
  #6  
Old October 11th, 2000, 07:19 PM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
I do run it from the command line and the output just prints to the screen. The timeout value has nothing to do with the problem. If a URL times out it is just counted as invalid. I can't understand what writing the output to a file would do when it already prints to the screen.

Any more ideas?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > script suddenly stops w/o error message


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway