Problems with perl and cron jobs

Hi all,
	I have a script that runs an SQL query and sends an email using sendmail.
It works fine if called using a browser. The email is sent with the correct
content in the message.
	If I run it using cron, I get the message but the content is not sent.
Meaning the body of the message is empty. I also get an email from cron that
contains and error message:
-----------
DBD::mysql::db do failed: You have an error in your SQL syntax near '' at
line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
----------

	Can anybody give me some insight as to why I get an error when cron
executes the script, but when I do it in a browser it works fine.

	Any help is appreciated.

David Gerler
Gerler Enterprises
PO BOX 16357
Chesapeake VA 23328
http://www.GerlerEnterprises.com/

Nationwide Dial-up from $12.45
http://www.EasySitesForLess.com/



0
president
9/8/2002 3:15:39 AM
perl.beginners 29335 articles. 3 followers. Follow

5 Replies
373 Views

Similar Articles

[PageSpeed] 47

David Gerler wrote:
> Hi all,
> 	I have a script that runs an SQL query and sends an email using sendmail.
> It works fine if called using a browser. The email is sent with the correct
> content in the message.
> 	If I run it using cron, I get the message but the content is not sent.
> Meaning the body of the message is empty. I also get an email from cron that
> contains and error message:
> -----------
> DBD::mysql::db do failed: You have an error in your SQL syntax near '' at
> line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
> ----------
> 
> 	Can anybody give me some insight as to why I get an error when cron
> executes the script, but when I do it in a browser it works fine.
> 
> 	Any help is appreciated.
> 
> David Gerler
> Gerler Enterprises
> PO BOX 16357
> Chesapeake VA 23328
> http://www.GerlerEnterprises.com/
> 
> Nationwide Dial-up from $12.45
> http://www.EasySitesForLess.com/
> 
> 
> 
> 

I ( we ) would need to see the script(s) that cron is calling to help 
out. However, I get that DBD error all the time :-) .. are you sure your 
sql statement is correct?

Thanatos


0
thanatos
9/8/2002 5:43:29 PM
> David Gerler wrote:
> > Hi all,
> > 	I have a script that runs an SQL query and sends an email
> using sendmail.
> > It works fine if called using a browser. The email is sent with
> the correct
> > content in the message.
> > 	If I run it using cron, I get the message but the content
> is not sent.
> > Meaning the body of the message is empty. I also get an email
> from cron that
> > contains and error message:
> > -----------
> > DBD::mysql::db do failed: You have an error in your SQL syntax
> near '' at
> > line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
> > ----------
> >
> > 	Can anybody give me some insight as to why I get an error when cron
> > executes the script, but when I do it in a browser it works fine.
> >
> > 	Any help is appreciated.
> >
> > David Gerler
> > Gerler Enterprises
> > PO BOX 16357
> > Chesapeake VA 23328
> > http://www.GerlerEnterprises.com/
> >
> > Nationwide Dial-up from $12.45
> > http://www.EasySitesForLess.com/
> >
> >
> >
> >
>
> I ( we ) would need to see the script(s) that cron is calling to help
> out. However, I get that DBD error all the time :-) .. are you sure your
> sql statement is correct?
>
> Thanatos
>
The script runs when called from a browser so I was thinking that it had to
do with the differences in how apache and cron worked or something like
that, so I didn't include the code. I will include the code below:

This is the sql statement from line 248:
$db->do("UPDATE Members SET won=won + 1 WHERE usernum=$biddernum");

This is the job I set in cronjobs:
* * * * *   /home/ezbid/www/cgi-bin/ua/item.pl?item=958 > /dev/null

I'm new to SQL also, so could the spaces around the "+" be the problem?

Dave

0
president
9/8/2002 7:02:04 PM
Could also be the env variables set by the httpd.conf file while they are
not set when the script runs by the crontab, try running it with the command
line and see if it gives you any errors.

I did have the problem with the sql scripts running with the apache until I
defined all the env variables in the httpd.conf and the script itself.

Regards,
Ebaad.
----- Original Message -----
From: "David Gerler" <president@gerlerenterprises.com>
To: "Thanatos" <thanatos@vcnet.com>
Cc: "Beginners" <beginners@perl.org>
Sent: Sunday, September 08, 2002 12:02 PM
Subject: RE: Problems with perl and cron jobs


>
> > David Gerler wrote:
> > > Hi all,
> > > I have a script that runs an SQL query and sends an email
> > using sendmail.
> > > It works fine if called using a browser. The email is sent with
> > the correct
> > > content in the message.
> > > If I run it using cron, I get the message but the content
> > is not sent.
> > > Meaning the body of the message is empty. I also get an email
> > from cron that
> > > contains and error message:
> > > -----------
> > > DBD::mysql::db do failed: You have an error in your SQL syntax
> > near '' at
> > > line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
> > > ----------
> > >
> > > Can anybody give me some insight as to why I get an error when cron
> > > executes the script, but when I do it in a browser it works fine.
> > >
> > > Any help is appreciated.
> > >
> > > David Gerler
> > > Gerler Enterprises
> > > PO BOX 16357
> > > Chesapeake VA 23328
> > > http://www.GerlerEnterprises.com/
> > >
> > > Nationwide Dial-up from $12.45
> > > http://www.EasySitesForLess.com/
> > >
> > >
> > >
> > >
> >
> > I ( we ) would need to see the script(s) that cron is calling to help
> > out. However, I get that DBD error all the time :-) .. are you sure your
> > sql statement is correct?
> >
> > Thanatos
> >
> The script runs when called from a browser so I was thinking that it had
to
> do with the differences in how apache and cron worked or something like
> that, so I didn't include the code. I will include the code below:
>
> This is the sql statement from line 248:
> $db->do("UPDATE Members SET won=won + 1 WHERE usernum=$biddernum");
>
> This is the job I set in cronjobs:
> * * * * *   /home/ezbid/www/cgi-bin/ua/item.pl?item=958 > /dev/null
>
> I'm new to SQL also, so could the spaces around the "+" be the problem?
>
> Dave
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>
0
ebaad1
9/8/2002 9:06:08 PM
David Gerler wrote:
>>David Gerler wrote:
>>
>>>Hi all,
>>>	I have a script that runs an SQL query and sends an email
>>
>>using sendmail.
>>
>>>It works fine if called using a browser. The email is sent with
>>
>>the correct
>>
>>>content in the message.
>>>	If I run it using cron, I get the message but the content
>>
>>is not sent.
>>
>>>Meaning the body of the message is empty. I also get an email
>>
>>from cron that
>>
>>>contains and error message:
>>>-----------
>>>DBD::mysql::db do failed: You have an error in your SQL syntax
>>
>>near '' at
>>
>>>line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
>>>----------
>>>
>>>	Can anybody give me some insight as to why I get an error when cron
>>>executes the script, but when I do it in a browser it works fine.
>>>
>>>	Any help is appreciated.
>>>
>>>David Gerler
>>>Gerler Enterprises
>>>PO BOX 16357
>>>Chesapeake VA 23328
>>>http://www.GerlerEnterprises.com/
>>>
>>>Nationwide Dial-up from $12.45
>>>http://www.EasySitesForLess.com/
>>>
>>>
>>>
>>>
>>
>>I ( we ) would need to see the script(s) that cron is calling to help
>>out. However, I get that DBD error all the time :-) .. are you sure your
>>sql statement is correct?
>>
>>Thanatos
>>
> 
> The script runs when called from a browser so I was thinking that it had to
> do with the differences in how apache and cron worked or something like
> that, so I didn't include the code. I will include the code below:
> 
> This is the sql statement from line 248:
> $db->do("UPDATE Members SET won=won + 1 WHERE usernum=$biddernum");
> 
> This is the job I set in cronjobs:
> * * * * *   /home/ezbid/www/cgi-bin/ua/item.pl?item=958 > /dev/null
> 
> I'm new to SQL also, so could the spaces around the "+" be the problem?
> 
> Dave
> 
> 
> 

Thanks Dave,

 From the looks of the SQL statement, won is an integer and you want to 
add one to it. When I do that I get the current value of won from the db 
, assign the value to a variable ( like $won ) and then do a ("update 
Memebers SET won='" . ( $won + 1 ) . "' WHERE ..." ).

Also, is $biddernum defined and does it contain a value? Is it possible 
that it could contain special characters, like a ' or "? If so, the you 
can use $new_biddernum = $db->quote( $biddernum ) so that the special 
chars are taken care of for you.

For an explaination of $db->quote, do a man DBI and search for quote.

Does any of that help?
Thanatos


0
thanatos
9/8/2002 10:04:23 PM
>
>
> > Also, is $biddernum defined and does it contain a value?
>
> I would look really closely at this statement as I think this is probably
> the problem (based on your error message and description).  More
> than likely
> you are setting it with some user input field on the web page
> (like a cookie
> even?)  and those things don't exist when you run it from cron.
>
> HTH,
> Tanton
>


Thanks to all for the help... I think this may have hit the nail on the
head. The script is one that I purchased and I'm not completely sure what is
happening... though I have a general idea. I need to run this script through
cron so that it will clean the closed auctions from the database. I think
the best solution is going to be to write a User Agent script to browse the
page and run that with cron. That way all the ENV variables and cookies are
set. Might not be the best method, but will be the quickest for me.

Again, thanks for all the replies.

Dave

0
president
9/8/2002 11:27:28 PM
Reply:

Similar Artilces:

Problems with Email from Cron job
Running openSUSE 12.1 with Linux 3.1.0-1.2-desktop x86_64, System: openSUSE 12.1 (x86_64), KDE: 4.7.2 (4.7.2) "release 5" and all patches up to date. I am having problems getting cron job to email me. I have tried simple test of system mail from console and am getting the following message in my /var/log/mail file. Second problem is I cannot stop the system from trying. Clearly the issue is one of permissions but what do I change and how? Code: -------------------- Apr 10 21:27:31 X3400server postfix/postdrop[28856]: warning: mail_queue_enter: create fil...

Problems, problems, problems
Name: Hans Halvorsen Email: capricorn_at_online.no Product: Thunderbird Summary: Problems, problems, problems Comments: Hi, I downloaded Thunderbird some time ago, and I was over-satisfied whit it and how well it worked. In fact it worked 100% PERFECTLY UNTIL I got an newer update version of it. Since then I' ve had nothing BUT trouble! I've checked adresses, notes, password, deleted accounts and made new one's, checked sign-ins and sign-outs, passwords inside and out, upside and down, so many times that my frustration now is about to turn into pure and major ...

Problems Problems Problems
So, I have OpenSUSE installed on my laptop and everything is working well, except the wireless. It almost seems that every time I run a KDE distro I can not get the internet to work. I've run YaST and used iwconfig. nothing is working for me. Please help -ZAD -- zadnik18 ------------------------------------------------------------------------ someone is going to tell you to supply some more information 'My wireless doesn't work - a primer on what I should do next - openSUSE Forums' (http://tinyurl.com/6peanc) this is one of the stick...

Problems, problems, problems
Name: Product: Firefox Summary: Problems, problems, problems Comments: I use FF all the time for work - I'm a software tester - the add-ons are invaluable. But v3.5 really has been a disappointment. It just keeps hanging all the time. And when Internet Explorer windows pop up, FF often just dies. It can't even restart itself - I have to manually kill the process every time; every update, every add-on that updates, "restart" fails - it's so frustrating. I hope v3.6 will be addressing this - PLEASE! Browser Details: Mozilla/4.0 (compatible; MSIE 7....

Problems problems and problems.
Name: A.A. Product: Firefox Summary: Problems problems and problems. Comments: I am not specific, but in short I can not use This site to listen music anymore, while I can in IE explorer. Just to let you guys know, new version messed something up. http://hypem.com/ Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Job job job..
This is more an iManager related question but I guess this is the place.. My Imanager hangs every time I click Ok on a job. (And Designer crashes at deploy..) Job have DirXML-AccessSubmitCommand write rights to the driver object.. Schedule is ok (run manually or * * * * *).. Public has sssActiveServerList browse on driverset.. iManager plugins are: (10.7.20090904 Novell Identity Manager Plug-ins for IDM 3.6.1) (10.7.20090904 Novell Identity Manager 3.6a - Job Plug-ins) Is there more things to manually configure? //Magnus -- magnus ---------------------------...

PROBLEMS, PROBLEMS, PROBLEMS.
Name: Product: Firefox Summary: PROBLEMS, PROBLEMS, PROBLEMS. Comments: Does Google's Chrome browser block out Firefox? Am having a lot of trouble getting Firefox to run after I run Chrome. No trouble what-so- ever before running Chrome. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1064 Safari/532.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see ...

System Mail - Cron Job
Please can somebody help me with an internal Mailing problem. SuSE 64bit 11.2 Avira AntiVirus Alpine & Pine Mailing Client. For a few short months system mail was being read with Alpine, then for a short while i wasn't getting any mail! When cron jobs run and when Avira updates mail is being sent to root@localhost and placed in the location: /var/spool/mail/*UserName* My Mailing client opens mail stored in the location: /home/*UserName*/Maildir Not sure just what has altered / changed, tried to alter where Alpine gets its mail from and failed. I don't k...

Problem saving an Image (not a beginner problem.. :) )
Ok, so here's the situation...  We're building an AJAX/.Net 2.0 site and one portion of the site displays a thumbnail image of an item.  You can click [edit] to edit the item, and a DIV drops down to allow you to edit the item.  One part of the item is a picture of that item.  Now since I can't gain access to their filesystem via client-side (FileSystemObject), to allow uploading of a picture, I placed an iFrame on the page which holds the Uploading Control and posts back to itself.  It works well and maintains the AJAX-y feel of the rest of the site.... ...

PB6/ORACLE7: Problem with changing a job in the job queue
Hi, I would like to set a job broken in my job queue from my Powerbuilder application with following code: EXECUTE IMMEDIATE "execute dbms_job.broken(57, true)"; But I get always this error: sqldbcode = 999 sqlerrtext = Invalid stored procedure parameter type of 'BOOLEAN' on 'JOB' Could anyone help me please? Thanks in advance Helga The Oracle OCI interface doesn't support booleans! So you have to create a separate procedure that you call from PB, passing it the jobnumber and an identifier to indicate true or false. This procedure will in t...

hplaserjet 1100 problem problem with iprint when submit the job
hi every body i have OES-Linux SP2 system installed and i was configure iprint as following : Driver store DrvStore.cceg and log-in to win-xp sp2 workstation and install iprint-client from //ipaddres/ipp ,so i load hp_laserjet 1100 driver for win-xp from IManager web then i create new printer manager , and the driverstore (novell-idsd) , printer manager(novell-ipsmd) is running after that i had create a new printer called hp_laserjet110 and use LPR and enter iprintgw PORT=LPR HOSTADDRESS=192.168.0.66 PRINTERNAME=PASSTHROUGH the problem when i install printer driver for las...

Problem with my problem?
Hi, folks. Three days ago, I posted that Sunbird was refusing to import the ICS file from the Firefox Calendar Extension. Nobody replied, so I can only assume that one of three situations exists: 1) The file is corrupt, and no one wants to give me the bad news; 2) This is a known problem with Sunbird, but no one knows the solution; 3) Everyone is hard at work 24/7 trying to figure out the solution to my problem (LOL). I've already discovered that I can copy and paste each event from the calendar extension to Sunbird one by one. Before I devote many hours of my life to th...

problem? what problem?
I just wanted to say is: Opensuse 11.2 gives many problems in comparison to other linux and possibly other previous opensuse. lol!lol!lol! I like to move it, move it. I like to move it, move it. I like to move it, move it. I like to...MOVE IT! rotfl! -- batou ------------------------------------------------------------------------ Crack is bad for you, you should lay down the habit. -- *it*'s all a game, avoiding failure, when true colors will bleed, all in the name of misbehavior and the things we don't need and more than ever, I hope to neve...

problems,problems
Name: Product: Firefox Summary: problems,problems Comments: I once loved Firefox, lately it just plain sucks, the latest version 3.6 something will no longer me to listen to MLB.com or Glenn Beck. It is also way slower (even with W7 and new machine). It always seems to be downloading updates and wasting my time. Guess I'll see how Google Chrome works! Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.11) Gecko/20100701 Firefox/3.5.11 (.NET CLR 3.5.30729) From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a ...

Problems Problems
Hi all,Well i am trying to use visio files in my application... I have added the libraries which are required for .NET to embed visio files...Bt it seems not to be working whenever i click files frm my .NET application bt it opens in Visio editor...Thanks in advance Regards,Srinivas RamanujanWords offer the means to meaning, and for those who will listen, the enunciation of truth !!!!!  Post Your Code for better understanding Your Problem.- Hardik (Software Developer,Surat,India)Please remember to click "Mark as Answer" on this post if it helped you. Well actually i...

Web resources about - Problems with perl and cron jobs - perl.beginners

Problem novel - Wikipedia, the free encyclopedia
Working class, or proletarian novels are often also social problem novels . This was in many ways a reaction to rapid industrialization , and ...

Where will ISIS attack next? Christmas travel a problem for intelligence agencies
IT’S that time of year when we let our guards down, when we relax and look forward to spending time with our loved ones over the festive break. ...

The Sound of Music review: How do you solve a problem like Cameron Daddo?
They have solved the problem of Maria with the casting of Amy Lehpamer, but Cameron Daddo doesn't cut the schnitzel as a lifelong military man ...

Dot-Sucks Domain Name Not Our Problem, Ottawa Says 2
The Canadian government has washed its hands of the "dot-sucks" controversy, as the new internet domain name begins to take root beside the more ...

Breitbart contributor says mass extinction via climate change isn’t a problem because of Jurassic Park ...
... about how science works. It did not go well for him: A Breitbart "journalist" claimed extinctions caused by climate change aren't a problem ...

Yet another problem with Comcast data caps: Customers have no idea why they’re exceeding their limits ...
Comcast sure knows how to bring out the love from its customer base. Cut Cable Today recently filed a FOIA request to the Federal Communications ...

BlackRock's $32 Billion Hedge-Fund Business Has a Little Problem
Yes, he runs the biggest asset management firm the world has ever seen. But right now, Laurence D. Fink has a little hedge-fund problem.

Court secrecy is a dangerous problem
Recently unveiled documents in the Remington faulty-trigger case show court secrecy can lead to unnecessary deaths, says Arthur Bryant.

Yesterday’s technologies, today’s problems
When I first heard the story, I didn’t believe it. I mean, really, a Paris airport forced to shut down because a computer running Windows 3.1 ...

De Blasio Unveils Plan to Tackle City's Homeless Problem
City workers will monitor the street homeless in most of Manhattan and outer-borough hot spots.

Resources last updated: 12/20/2015 5:35:16 AM