It is currently Fri Mar 29, 2024 9:30 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Starting a Perl script
PostPosted: Sat Mar 04, 2006 12:17 pm 
Noobie
Noobie

Joined: Sat Nov 05, 2005 5:01 pm
Posts: 4
Simple question: how do I start and stop a Perl script? For example a very simple script at end of this message will connect to the database and poll it forever to a value and update the database. How do I start and stop it?

Thanks!

-----------------------------------------------

#!/usr/bin/perl -w
use DBI;

$DSN = "DBI:mysql:database=guestdb";
my $dbh = DBI->connect($DSN) || die "Can't connect";

while ( 1 ) {
my $qs = $dbh->prepare("SELECT * FROM guestTbl");

$qs->execute();

while (my $rs=$qs->fetchrow_hashref()) {
print "Name: ",$rs->{'name'}," EMail: ",$rs->{'email'};
print " msgFrom: ",$rs->{'msgFrom'},"\n";
}

my $qs = $dbh->prepare("UPDATE guestTbl SET name='Bob'");
$qs->execute();
}

$qs->finish();
$dbh->disconnect;

exit;


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 04, 2006 12:52 pm 
Moderator
Moderator

Joined: Thu Dec 15, 2005 2:59 pm
Posts: 681
Location: England
exit; Should stop it once the script has finished.

_________________
Mountain biking forum ;)
Ponds and fishkeeping :D


Top
 Profile  
 
 Post subject: Starting
PostPosted: Sat Mar 04, 2006 1:05 pm 
Noobie
Noobie

Joined: Sat Nov 05, 2005 5:01 pm
Posts: 4
Ok, but it runs in a infinite loop so technically exit will never be reached. And more important, how do I start it? Do I have to write a special PHP page just to start this script with something like the system() function?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 04, 2006 1:14 pm 
Moderator
Moderator

Joined: Thu Dec 15, 2005 2:59 pm
Posts: 681
Location: England
To start it you could just use simple commands like submit and form action. So when the submit is pressed, it will start this script.

_________________
Mountain biking forum ;)
Ponds and fishkeeping :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: fhmagic, KJ, Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011