Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cfengine in tcl?

10 views
Skip to first unread message

Mike

unread,
Oct 6, 2006, 1:57:03 PM10/6/06
to
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

unread,
Oct 6, 2006, 2:31:59 PM10/6/06
to

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-week) == 0} {
exec sh -c {find /tmp -mtime +30 -print | xargs rm -rf}
}

Stéphane A.

unread,
Oct 7, 2006, 1:54:08 AM10/7/06
to
> ...
> ----- cftcl program/controlling script

> proc action {name test body} {
> if {[info exists actions($type)] == 0} {
> set actions($type) {}
> }
if {![info exists actions($type)]}
is better

> if {[string length $test] <= 0} {
> set test 1
> }
if {$test eq ""}
is better

> if {[string length $body] <= 0} {
> set body "puts action $name with test $test and body $body has an empty 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éphane

0 new messages