Page 1 of 1
java and php
Posted: Thu Sep 29, 2005 8:46 am
by shiznatix
heres my problem. i can't remember to set my alarm at night and i sleep in and miss my first class, atleast once a week. this is bad. what i want to do is use php to open up my schools website and find out when my first class is the next day. then it will send that variable to a (probably java) program which will then set itself to turn on a song and turn up the volume to max 2 hours before that class happens to start.
questions:
- how do i send variables from php to a java program
- is this possible?
- can anyone think of a way this could be done in only php, so i don't have to mess around with java
- other sugestions would be welcome for ideas as to how to go about doing this
thanks
Posted: Thu Sep 29, 2005 9:37 am
by Jenk
You could read the time table, using fopen/fread etc. and preg_match the line that has the relevant time for it and store it in a DB.
You'd have to use windows scheduler or something to load the page, and then same for the java app which could read the time from a database.
But tbh.. just get a louder alarm...
Posted: Thu Sep 29, 2005 9:37 am
by echo
you could probably use just java to pull the info from the page
Re: java and php
Posted: Thu Sep 29, 2005 9:44 am
by Buddha443556
shiznatix wrote:
questions:
- how do i send variables from php to a java program
Could pass it on the command line
See:
Main
shiznatix wrote:
- can anyone think of a way this could be done in only php, so i don't have to mess around with java
I would use only one language just to make it easy to maintain. Might be interested in
NirCmd which allows you to control the system volumn from the command line. Of course, STARTing music from the commandline also possible. Any language that can execute system commands should work.
shiznatix wrote:
- other sugestions would be welcome for ideas as to how to go about doing this
I'd probably do it in Perl.

Posted: Thu Sep 29, 2005 9:46 am
by dbevfat
I see 2 distinct responsibilities here:
1) fetch data from web and write the information locally
3) read local information and play song at the correct time
The first one can be any programming language that can handle sockets and write to a file or DB. The second one must be able to read from a file/db and play the song, for which I'm not sure php can, unless you have a POSIX compatible system. In that case I think you can use
http://sourceforge.net/projects/cursed-player/.
I think you're better off using java, because you'd have to run php automatically, too, to fetch remote data. But an application in java can easily be run all the time, or just scheduled (in that case it can fetch new data when it is run in the morning) so you have it turned off most of the time.
Besides, you'd have to make up a way of communication between two programs, which means some work in both of these two programs.
Regards
Posted: Thu Sep 29, 2005 9:47 am
by shiznatix
Jenk wrote:But tbh.. just get a louder alarm...
thats not the problem, i just always forget to set it at night, usually becuase i drank too much

.
but i don't know java very well, actually i am just learning it. here is my idea:
have this java program stay open on my computer at all times, just somtin running in the background. then have the java program call a php script to get the time that my class starts, then have that php script either write to a db and have java get that time or have php just directly return a value to the java program. then have java sit and wait until the time that is set and then when that time comes around it plays a mp3 on full volume. basically can i use java to:
-get information from a online db
-change my volume settings on my computer
-play a mp3 on loop until i hit a certain key combo