Another CRON question

S

Sean O'Dwyer

Can I pass a variable to a Perl script via cron? It seems not from the
following error message...

/bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such
file or directory



In my crontab I have...


MAILTO="(e-mail address removed)"
HOME="/cgi-bin/"
*/5 * * * * /cgi-bin/script1.cgi
*/3 * * * * /cgi-bin/script2.cgi?action=call_a_routine


....is this just daft?



The action variable is parsed by a subroutine which then figures out
which routine to call: if ($action eq "call_a_routine") {&call_that_baby}

Solution would be to move the routines I want to call into their own
script and simply call that new script by cron. Yeah?

Ideally, for project mangement purposes, I'd like them all in the same
script, with some routines triggered via http, some called by cron. But
maybe that's asking too much....?

TIA,

Sean
 
J

Jürgen Exner

Sean said:
Can I pass a variable to a Perl script via cron?

What do you mean by "passing a variable"?
Passing an argument aka parameter aka option aka ...?
It seems not from the
following error message...

/bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such
file or directory

Well, does the file with the name
"/cgi-bin/script2.cgi?action=call_a_routine" exist?

Oh, by the way: this command does not contain any parameter.
Maybe you meant something like
/cgi-bin/script2.cgi -action call_a_routine
In my crontab I have... [...]
*/3 * * * * /cgi-bin/script2.cgi?action=call_a_routine

Well, again, there is no parameter here, just a funny looking and very long
file name
The action variable is parsed by a subroutine which then figures out
which routine to call: if ($action eq "call_a_routine")
{&call_that_baby}

Ok, so you are asking about parameters/options/arguments/...

jue
 
S

Sean O'Dwyer

Sorry, my terminology seems to be way off.

I'm used to calling scripts via http and getting the script to run a
certain subroutine based on the data I send it. I'm trying to do the
same by cron. I've fallen back to my "just put it in a separate script"
plan, but I'm curious to know if there's a way to do it as I'd prefer.

Kind regards,

Sean
 
G

Gregory Toomey

It was a dark and stormy night, and Sean O'Dwyer managed to scribble:
Can I pass a variable to a Perl script via cron? It seems not from the
following error message...

/bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such
file or directory



In my crontab I have...


MAILTO="(e-mail address removed)"
HOME="/cgi-bin/"
*/5 * * * * /cgi-bin/script1.cgi
*/3 * * * * /cgi-bin/script2.cgi?action=call_a_routine


...is this just daft?

Yes. You probably need

HOME="/fully/qualified/path/cgi-bin/"

Also, I'm not sure why use use */5 and */3.


gtoomey
 
J

John W. Krahn

Gregory said:
It was a dark and stormy night, and Sean O'Dwyer managed to scribble:

Yes. You probably need

HOME="/fully/qualified/path/cgi-bin/"

Also, I'm not sure why use use */5 and */3.

*/5 means to run every five minutes, */3 every three minutes.

man 5 crontab



John
 
M

Martien Verbruggen

*/5 means to run every five minutes, */3 every three minutes.

man 5 crontab

As long as you do this on a system where cron supports this sort of
syntax in a crontab file and man supports this way of asking for section
5.

Martien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top