|
-
Mar 12th, 2002, 09:22 AM
#1
Thread Starter
Addicted Member
PHP or CGI?
What I need to do is some nightly maintenance stuff (send out emails if a certain date is reached, update the mysql database, etc). Now I am good in PHP but not so good with server side stuff like CGI. Is there a way I can write a time specific program that will run on the server, lets say every night at 1:00am eastern, or do I need to write a CGI or Linux like program on the server? I really don't know where to start with this one.
Thanks
-
Mar 13th, 2002, 10:25 AM
#2
Thread Starter
Addicted Member
hmm.. not sure if this is what I need. I need it to run on a Linux box and all I see is UNIX stuff.
-
Mar 13th, 2002, 01:15 PM
#3
Thread Starter
Addicted Member
I think I'm getting the hang of it... I got me a file in the cron.daily folder that goes through the database and just does an email to me but when I try to test it... (./testit) it tells me No file found.... I changed the persmissions on the file already but then I get that error. Anybody have an idea? Here's what my simple program looks like...
#!/usr/bin/perl
use DBI;
use strict;
my $database = "thedb";
my $data_source = "DBI:mysql:$database;"
my $username = "thename";
my $password = "thepass";
my $dbh = DBI->connect( $data_source, $username, $password)
or die "Can't connect to $data_source: $dbh->errstr\n";
my $sth = $dbh->prepare("SELECT * FROM table");
$sth->execute or die "Unable execute query:$dbh->err, $dbh->errstr\n";
my @row;
while(@row = $sth->fetchrow_array) {
print "$row[0] $row[1]\n";
}
$sth->finish;
$dbh->disconnect;
my $sub="Desert Rose";
my $mailto="thegoldenshogun\@aol.com";
my $message ="The shiznit worked";
## Mail info
open(MAIL, "|/usr/sbin/sendmail $mailto");
print MAIL "Subject: $sub\n\n";
print MAIL "$message";
close(MAIL);
exit(0);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|