|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hello guys,
Anybody knows how to run cron job to call a cgi script, but what I need is passing in parameters Example: /home/path/myscript.pl?x=123&y=abc So how would I set up the cron so that it will execute that script WITH those params One more question: to call the above script (with params) under unix (or linux), how would you put the params? Thanks a lot, ------------------ http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr http://www.guideclick.com/ - Qualified webmaster resources (affiliate programs, web design, tips) ------ Son |
|
#2
|
||||
|
||||
|
crontab -e: edits a new crontab
crontab -r: removes a crontab crontab -l: lists the crontab then just fill in the paramaters for when you want it to run: min hrs day mos dow script to run 30 15 * * mon /home/path/myscript.pl?x=123&y=abc would run a crontab every monday at 3:30PM. use man crontab for more help [This message has been edited by tron (edited August 08, 2000).] |
|
#3
|
|||
|
|||
|
30 15 * * mon /home/path/myscript.pl?x=123&y=abc
isn't going to work. You'll get a perl error (or the person owning the crontab will get an e-mail with the error) saying that it can't find/run "/home/path/myscript.pl?x=123&y=abc". You need to pass it on using the @ARGV array: 30 15 * * mon /home/path/myscript.pl "123" "abc" then in the script say: $x=$ARGV[0]; $y=$ARGV[1]; That will work. [This message has been edited by JonLed (edited August 08, 2000).] |
|
#4
|
|||
|
|||
|
Heh, was fixing that as you where saying it.
[This message has been edited by JonLed (edited August 08, 2000).] |
|
#5
|
|||
|
|||
|
Thank guys!
So calling the script from the command prompt of unix I would do the same thing? Is there a solution that I don't need to modify the code? ------------------ http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr http://www.guideclick.com/ - Qualified webmaster resources (affiliate programs, web design, tips) ------ Son |
|
#6
|
|||
|
|||
|
You'll need to modify the code if you plan on running it from the command line.
|
|
#7
|
|||
|
|||
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by JonLed:
You'll need to modify the code if you plan on running it from the command line.[/quote] Not entirely true if you use CGI.pm to parse the parameters -- just specify your command line arguments as name=value pairs, e.g. /home/path/myscript.pl x=123 y=abc |
|
#8
|
|||
|
|||
|
Well I never use CGI.pm, so it's not possible for me
. |
|
#9
|
|||
|
|||
|
Can you tell me more specific how to parse in CGI.pm? Thanks
------------------ http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr http://www.guideclick.com/ - Qualified webmaster resources (affiliate programs, web design, tips) ------ Son |
|
#10
|
|||
|
|||
|
The following code assumes you have a page that has an <input> named "FileName".
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> #!/usr/local/bin/perl -w use CGI; $q = new CGI; print $q->header; print $q->start_html; # get filename from submitted form my $filename = $q->param('FILENAME'); # if other parameters are available # from the form..... my $otherParm = $q->para('otherParm'); # and so on for any others. # you might open file or showError and die. open (FILE,$filename) or &showError("can not open $filename"); @FILE=<FILE>; close(FILE); print '<pre>'."@FILE".'</pre>'; print '</P>',$q->end_html; sub showError { my $error = @_; print "ERROR - $error<BR>n"; print '</P>',$q->end_html; exit; } [/code] |
|
#11
|
|||
|
|||
|
oops....that should have been "a parameter named 'FILENAME'", not 'FileName'.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Cron question for perl script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|