Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 8th, 2000, 09:05 AM
123finder.com 123finder.com is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 73 123finder.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #2  
Old August 8th, 2000, 10:27 AM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: the master control
Posts: 234 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 46 sec
Reputation Power: 9
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).]

Reply With Quote
  #3  
Old August 8th, 2000, 01:07 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
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).]

Reply With Quote
  #4  
Old August 8th, 2000, 01:19 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
Heh, was fixing that as you where saying it.

[This message has been edited by JonLed (edited August 08, 2000).]

Reply With Quote
  #5  
Old August 8th, 2000, 05:20 PM
123finder.com 123finder.com is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 73 123finder.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #6  
Old August 9th, 2000, 01:51 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
You'll need to modify the code if you plan on running it from the command line.

Reply With Quote
  #7  
Old August 9th, 2000, 10:51 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
<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

Reply With Quote
  #8  
Old August 9th, 2000, 11:58 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
Well I never use CGI.pm, so it's not possible for me .

Reply With Quote
  #9  
Old August 9th, 2000, 05:41 PM
123finder.com 123finder.com is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 73 123finder.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #10  
Old August 10th, 2000, 07:18 AM
goBoating goBoating is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Charleston, SC, USA
Posts: 10 goBoating User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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]

Reply With Quote
  #11  
Old August 10th, 2000, 07:19 AM
goBoating goBoating is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Charleston, SC, USA
Posts: 10 goBoating User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
oops....that should have been "a parameter named 'FILENAME'", not 'FileName'.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Cron question for perl script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway