CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
A time script [wink]

 



etheracide
journeyman

Jul 30, 2001, 1:39 AM

Post #1 of 7 (1559 views)
A time script [wink] Can't Post

I will attach my latest script. It is only halfway complete because I am stuck on the first half. Once I get it working, I will work on the second half of it.

The script creates an HTML page with a form on it. This form displays the users current time. By changing the hour difference (HOURADJUST) in the script, each use can get it to display their own time.

There is then a dropdown box which allows the user to select a number of hours they want to set the alarm for.

Then when they click on submit, it is supposed to to create a NEW html page which will display the user's current time, as well as the user's time that they set the alarm for. This is figured out by taking the current time and adding the amoung of hours the user wanted to set the alarm for...naturally.

When I run the script, it create the HTML page with my time set. There is the drop down box. i select a time and click the button to send it to the settime subroutine which is where the hours are added to the current time to set the time that the 'alarm' should go off. After I click the button, I can see the script run and the URL in the address boxes changes to scriptname.cgi?set But the HTML page shows exactly the same thing as the original page.

Here is the URL to try my script http://etheracide.hypermart.net/cgi-bin/alarmclock/wickedalarmclock.cgi

This will show you what happens. And you can read my source code to see what I have done so far. I will eventually set an 'event' to occur at the new set time, but only after I get this part to work. i am guessing that the problem could lay first within my calling up the new HTML page...I could be wrong...I could be right heh

I guess read through everything if you have the time and patience and shoot some ideas at me. Thanks as always.
Smile


#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();


Pro_4
User

Jul 30, 2001, 7:54 AM

Post #2 of 7 (1549 views)
Re: A time script [wink] [In reply to] Can't Post

Well the reason why scriptname.cgi?set doesnt do anything is because you didnt set it to do anything... soo you will need to add something like this to it..
(i am pretty sure it will work this way but normally i have scriptname.cgi?action=set )

Code
$action =$ENV{'QUERY_STRING'}; 
if ($action eq "set") {
insert set sub here
}
if ($action eq "") {
do regular thing before setting it
}

That should do it.

@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


etheracide
journeyman

Jul 30, 2001, 9:23 AM

Post #3 of 7 (1544 views)
Re: A time script [wink] [In reply to] Can't Post

Thank you very much. This is why I post in "Beginner". heh I changed everything to actually create the action within the settime...But I am generating an error..atleast one. I am on hypermart.net's server and they print out errors automatically..and they show only older errors so it isn't showing me what the problem is.

I will attach a copy of the script as I have it now and maybe you can see where the problem lies.

PS. I tried it first keeping it as scriptnamte.cgi?set and then I tried scriptname.cgi?action=set and they both aren't working. But once I get whatever the problem is solved..then either one will work. Thank you again.

#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();


Pro_4
User

Jul 30, 2001, 7:00 PM

Post #4 of 7 (1535 views)
Re: A time script [wink] [In reply to] Can't Post

Well for the scriptname.cgi?action=set you have to change the $action part.

Code
($useless, $action) = split(/\=/,$ENV{'QUERY_STRING'});

Just replace $action = $ENV{'QUERY_STRING'} with the above and then try the scriptname.cgi?action=set thing. Otherwise i dont see anything wrong with your program.

@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


etheracide
journeyman

Jul 31, 2001, 3:11 AM

Post #5 of 7 (1529 views)
Re: A time script [wink] [In reply to] Can't Post

Thank you very much! That got it working!

For the next part. I was planning on creating a subroutine that will run say every 5 minutes to check if the current server time is equal to or greater than the time that the user set in the set action of the script. If the current server time is less than the user's set time, then I would like for it to check again in..say...5 minutes. And when it is true that the current time is greater than or equal to the set time, then i would like for the script to redirect to a new HTML page that is created by the cgi.

I basically know how I want to do everything, but I am not sure exactly how I should go about making the script check every 5 minutes or so to see if the times part is true.

Any suggestions? =0) Thanks a billion...and then some!

#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();


Pro_4
User

Jul 31, 2001, 8:09 AM

Post #6 of 7 (1525 views)
Re: A time script [wink] [In reply to] Can't Post

Well for this next part, it is something i cant do yet... it is called crontab. Search the forums for that and you might be able to figure it out, or maybe one of the genious perl programmers lurking around here might be able to help.


hehe good luck :)

@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


etheracide
journeyman

Jul 31, 2001, 5:22 PM

Post #7 of 7 (1516 views)
Re: A time script [wink] [In reply to] Can't Post

Well thank you very much for all of the help that you have provided to this point !! Smile

And thank you for the crontab suggestion. I will begin looking into that, you at least gave me a place to start. I will also place this into a more appropriate category now. I continued on here because of the help that you had given me up to this point. It was in hopes that you might know how to further the script heheh

Maybe someone will catch it here and I will post in the other forums where this is appropriate. Thank you again..

#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives