Jon Clausen <[EMAIL PROTECTED]> wrote: <snip> > resulting QUERY_STRING, and echo back to a new page. This all works > pretty much as I want it, even if my sed scripts *are* a bit clunky... > > Next step will be to have that data written to a file instead of just > out to a page. Now, since this whole thing is meant to be time-centric > (run at specified times) the logical thing to do is have the cgi-script > write to a crontab, with the appropriate format. > > For a number of reasons, I'm not very comfortable with the idea of > letting my own scripts modify root's crontab, one of the more obvious > being that my scripts would have to run with root-privs to do that.
Take it one step at a time. I'd make a backup of the files you will be modifying. Experiment with what you want to do as root, then worry about the uid thing. It is not like you're going to have to send hours reinstalling a full distro. Just hit reset if things go really bad. ;-) > > I'm beginning to think that I should probably add a uid to handle all > this crap, instead of letting it run as sh-hhtp, but either way I'd like > to get some clarification on a couple of issues: > > 1) How does cron handle itself on Bering? I.e. will it find and execute > a user-crontab by itself? cron on dachstein/bering plays into your game plan. You do not have to use crontab -e to edit the file. Here's /etc/crontab. Look at run-parts command. ls -l cr* under /etc. It looks like you throw the file you want executed into a directory. runparts runs all the stuff in the directory. # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file. # This file also has a username field, that none of the other crontabs do. # SHELL=/bin/sh # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 42 6 * * * root run-parts --report /etc/cron.daily 47 6 * * 7 root run-parts --report /etc/cron.weekly 52 6 1 * * root run-parts --report /etc/cron.monthly > > 2) Any tricks/hints/pointers on how to actually writing to a file? Or > rather *modifying* a file that is already there (i.e. changing some of > the fields in a crontab line from f.x. 30 6 * * * to 00 7 * * *) Since you mention that your knowledge of sed is growing, that would be your tool here. Look at the \( and \). You have up to nine of them to replay values with \1 to \9, etc. I call these dog teeth because I imagine the character art to be dog fangs and you are taking a bite out of the line--YMMV here. Also consider first of line in sed. This is the ^. You may need any character too that is ., the period. The idea is to hold the parts of the line in multiple occurrences of \( \). Replace the parts of the line that changes with your new values and replay static values with \1. I leave you plenty of research room here. In some of my work I use what I call search tokens, PLACE_STEP_MOTOR_VALUE_HERE, for example. It makes an easy target in sed. You will have to experiment in the crontab line in how to apply this. > > 3) Are there any good candidates (scripts/routines) already present in > Bering/packages, that I can use as starting point for 2) ? I think just pick a cgi page to modify. You would want some sort of confirmation page to print in weblet. Paint the page with the normal echos. Then echo string > desired_file_name if a whole file. Otherwise, sed a line with your new value. Perhaps checkmem is an example. Think of how to use the level variable. Think of above case statement and below case statement. > > I must admit that I haven't done a great lot of research on this, before > asking. But, as usual, what I'm asking is more on the order of 'where > to look for docs on this' or 'advice/considerations, please?' rather > than 'tell me what to write where', so I hope it's o.k... I hope I complied with your wishes. I used the sed manual pages, and Unix in a Nutshell to learn more about pattern matching in sed. They call pattern matching Regular Expressions. > > Man, this just keeps growing... but it's *fun*! (Next thing you know, > I'm gonna want to have the ability to specify different runtimes, for > different days of the week ;) > > Oh yeah, one other thing; > Setting the time to open/close is all very nice, but I'd like to be able > to specify a *duration* of the 'sunrise' as well... Ummm. I don't know. Have a scheduled job to start? Pass a parameter into job i.e. sunrise 20. Do stuff to turn motor on. After all motor control is done call sleep with value i.e. sleep $1. Then do more motor control to close blinds or whatever? > > There are ~576 'steps' of the stepper motor from extreme-open to > extreme-closed. Any idea how to distribute x steps per minute...? > > TIA > > Jon Clausen > Have fun exploring, Greg Morgan _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm ------------------------------------------------------------------------ leaf-user mailing list: [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/leaf-user SR FAQ: http://leaf-project.org/pub/doc/docmanager/docid_1891.html
