PDA

View Full Version : Time



cyanid3
28th October 2004, 05:48 PM
I want to make a startup script that will choose between different wireless networks based on what time it is. I'm not the most familiar with writing shell scripts, i usually just end up figuring out how to do specific things as I go.

What I want to do: (the syntax is probably wrong, I can figure it out)

if "time variable" = before some time
use this Wireless network
else
use the other wireless network

I just need to find out what I would use as the "time variable"

There probably is some program that works in a similar way. If anyone knows of one, that would be great too

Thanks.

tchung
28th October 2004, 06:30 PM
I would suggest to use "date" command.

For example, "date +%X" gives you current time.

[tchung@tchung-linux tchung]$ date +%X
10:24:38 AM

See man date for detail.

Thomas

GreyGeek
28th October 2004, 06:41 PM
Go to
http://www.tldp.org/LDP/abs/html/
and you'll find an excellent how-to on advanced bash scripting.
That site also links to a downloadable PDF file too.
Consider using the %s option, which is seconds since midnite 01/01/1790 to set the "time variable" to some future time. Then you can test against $(date +%s) to see if 'now' is greater than "time variable"

cyanid3
28th October 2004, 10:33 PM
See, that's why I love this forum. You ask a question that probably doesn't make sense, and you get way more information than you were counting on. Thanks guys, this helps a lot.