I'm trying to write a script that will check the date and only run Monday thru Friday between the times 7am an 6pm. Any ideas, I'm looking the help files just not sure of the best way to use the script examples listed.
Is the script going to run constantly during the day, or does it just need to check on startup?
Probably the easiest way to do this is to use the ltimemisc command to have the script determine what day it is and then use ltimeints command with the $LTIME system variable to get the current minute, hour, etc.
The waituntil command might be useful in this situation as well. You can use it to pause your script (instead of closing it outright) until the specified time and day.
The script will be running 24 hours a day. I did figure out from looking at your site how to get the script to check if it is a week day, just need to figure out about the time issue now.
Could I use the ltimestrs $LTIME DateString TimeString and do an if statement for the TimeString ?
Also could you point me to information on how to write and call parts of the script as procedures, right now everything is all grouped togeter and I think it would work better if I did calls of procedure.
In that case, I think using ltimeints like I mentioned above would be the easiest way to do this. The script would run the command to break the time value into its component parts (the help file has a sample script that shows how to do this) and you could check the value of the integer variable holding the hours value. If it is less than 7 or greater than 18, then the script should pause until the proper time is reached. I think this would be easier than getting the value from ltimestrs in a string format and trying to do a compare in that manner.
The help file probably explains it better than I can here (check out the Procedures and Functions topic in the help file for starters) but here are the basics. The format for a procedure is:
proc procname
code...
endproc
where procname is the name of the procedure. To call this procedure, you would use this syntax:
procname()
When procname was done executing, it would return to where it was called from.
Procedures are not able to access variables from other procedures or the main procedure directly unless you either declare the variable as a global (meaning it is declared above proc main in your script) or you pass its value to the procedure. Again, since the help file explains it better than I can, check out the discussion of the param command in the help file.
Ok, great thanks I think once I get the time check done the script will be done. The whole script is 700 lines of code, but thats to you and the forum it was fun and a lot easier to get done.
sounds like quite a bit of work ... one fun thing i liked adding to my scripts, right before i compiled them into a wax file for distribution was this ...
a shelf life so to speak ...
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iYear > 2005
halt
endif
useful in case of downsizing, but on a more serious note, you can make it where your script will only be able to be run during the maintenance hours ...
for example
if iHour < 0700
halt
endif
if iHour > 1800
halt
endif
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.