On 18-Feb-02 Ted Harding wrote:
Hi Jenny,
3. I don't know how one "registers" an access to a web page within Linux. Suppose, however, that the access updates some file called "acces_log". Then the script in (1) could be
touch watch_access_log while true ; do if [ access_log -nt watch_access_log ] ; then cat appended_file >> other_file fi sleep 10 touch watch_access_log done
It occurs to me that, while you can set the "sleep" to anything you like down to 1 second (but you can't set it smaller), you might have two or more web-page accesses during the sleep period; and you wanted to do the append for every access. The only way I can see how to get round that would be for the web-access to trigger a signal to another program which then immediately did the append. I don't know how you would arrange for the signal to be sent. However, you can start up a shell which can detect signals by using the "trap" command in bash, on the lines of the (outline) script #!/bin/bash trap "command_to_append_file" SIGINT while true; do <nothing_much> ; done For example, try the following little script (call it "temp"): #!/bin/bash trap "ls -l" SIGINT while true ; do true > /dev/null ; done and then chmod 755 temp 1. Make sure you have another window from which you can do killall -15 temp Then start temp with the command temp Now keep trying to interrupt it with ^C -- each time, you will get the output of "ls -l". When you're happy about that, kill it as above from the other window. To make it work in the background, do temp & and now, from anywhere, you can killall -2 temp which will send it the SIGINT signal, resulting in a prompt "ls -l"; and this will continue until you "killall -15 temp". You can use this mechanism instead of the "watch" loop in my other mail provided you have a way of getting the web-page access to send the signal to the above program. That I can't help with. The only thing you need to change in the script is to substitute "cat appended_file >> other_file" for "true > /dev.null". Alternatively, if you reckon that "sleep 1" (or whatever) is safe from multiple wep-page accesses, then you can stick to the other script which at least is independent of getting something else to send the signal, since all it does is watch a file. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 18-Feb-02 Time: 14:26:55 ------------------------------ XFMail ------------------------------