For Programmers: Free Programming Magazines  


Home > Archive > Tcl > October 2006 > cfengine in tcl?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cfengine in tcl?
Mike

2006-10-06, 7:02 pm

Has anyone thought of writing or have cfengine in tcl? I have
tclsh on all my boxes, but compiling cfengine on all my boxes
is a problem, and I prefer to have cfengine as a script rather
than a binary. I know there is cfperl, a cfengine-look-alike
in perl. Not all my boxes have perl.

Mike
Mike

2006-10-06, 7:02 pm

On 2006-10-06, Mike <mikee@mikee.ath.cx> wrote:
> Has anyone thought of writing or have cfengine in tcl? I have
> tclsh on all my boxes, but compiling cfengine on all my boxes
> is a problem, and I prefer to have cfengine as a script rather
> than a binary. I know there is cfperl, a cfengine-look-alike
> in perl. Not all my boxes have perl.
>
> Mike


This doesn't have to look like cfengine, just be the same sort of
idea. Thinkg out loud, could it be this simple? The main script
does the defines, figuring out IP addresses, time of day/month/year,
and the other things that cfengine defines and creates those
proc's like 'actionsequence' and 'action'. Then the cftcl
configuration script does

----- cftcl program/controlling script
proc actionsequence {actions} {
set $::actionsequence actions
}
proc action {name test body} {
if {[info exists actions($type)] == 0} {
set actions($type) {}
}
if {[string length $test] <= 0} {
set test 1
}
if {[string length $body] <= 0} {
set body "puts action $name with test $test and body $body has an empty body"
}
lappend actions($type) [list test body]
}

------ cftcl.cfg configuration file
require cvstcl ;# what's the name of the pure tcl cvs client package?

source cf.groups.tcl
source cf.sun.tcl

actionsequence {copy tidy}

action copy {} {
# copy something
}

action tidy {$defines(day-of-w) == 0} {
exec sh -c {find /tmp -mtime +30 -print | xargs rm -rf}
}
Stéphane A.

2006-10-07, 4:10 am

> ...
> ----- cftcl program/controlling script
> proc action {name test body} {
> if {[info exists actions($type)] =3D=3D 0} {
> set actions($type) {}
> }

if {![info exists actions($type)]}
is better
> if {[string length $test] <=3D 0} {
> set test 1
> }

if {$test eq ""}
is better
> if {[string length $body] <=3D 0} {
> set body "puts action $name with test $test and body $body has an emp=

ty body"
> }

[string length $body] cannot be negative
IMHO doing if {$body eq ""}
is better
> lappend actions($type) [list test body]

You probably mean [list $test $body] ?
Try your script step-by-step on a console (Tkcon is fine)
and you'll see :
% set test 1; set body go
go
% list test body
{test body}
% list $test $body
{1 go}
> }
>
> ------ cftcl.cfg configuration file
> require cvstcl ;# what's the name of the pure tcl cvs client package?

I do not know about such a package in pure-tcl.
But packages are loaded by the package command :
package require foo
> ..



Regards,
St=E9phane

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com