[email protected] wrote on 2009-12-10 12:09:57:
> Christopher Browne wrote:
> > - In reflecting on it, I think I'd like for some of the derived
classes
> > to be derived out of data residing in external sources like
LDAP/DBMS.
>
> Yes, a native ability to import, AND export, class information would be
> the bees knees...
This may be the future for methods that is alluded to in the reference
manual. One can currently read information from external files but the
implementation does not seem to allow the type of things we'd like to see.
For instance suppose I had a file like this.
/etc/profile,root,root,0644
/etc/cron.allow,root,root,0600
/etc/motd,root,root,6044
This is a neat way to separate the data and read from it. Readstringarray
almost allows use to do this except that the function uses the first entry
as the array name. This makes things impractical (or so it seems to me).
As Erlend mentioned a more Perlish way would be nice:
nwat...@tofrcpl58903 ~/tmp $ cat fileperms.txt
/etc/profile,root,root,0644
/etc/cron.allow,root,root,0600
/etc/motd,root,root,0644
nwat...@tofrcpl58903 ~/tmp $ cat foo.pl
#!/usr/bin/perl
use Data::Dumper;
open (FH, "<fileperms.txt") or die "cannot open file $!";
while (<FH>) {
chomp;
(
$files{"trg"},
$files{"usr"},
$files{"grp"},
$files{"mod"}
) =
split(',');
foreach $k (keys %files){
print "'$k' => string '$files{$k}';\n"
}
print "\n";
}
close FH;
nwat...@tofrcpl58903 ~/tmp $ ./foo.pl
'grp' => string 'root';
'trg' => string '/etc/profile';
'usr' => string 'root';
'mod' => string '0644';
'grp' => string 'root';
'trg' => string '/etc/cron.allow';
'usr' => string 'root';
'mod' => string '0600';
'grp' => string 'root';
'trg' => string '/etc/motd';
'usr' => string 'root';
'mod' => string '0644';
CONFIDENTIALITY WARNING
This communication, including any attachments, is for the exclusive use of
addressee and may contain proprietary and/or confidential information. If you
are not the intended recipient, any use, copying, disclosure, dissemination or
distribution is strictly prohibited. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
communication and destroy all copies.
AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage
exclusif de la personne à laquelle il s’adresse et peut contenir de
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en
est pas le destinataire, nous l’avisons par la présente que toute diffusion,
distribution, reproduction ou utilisation de son contenu est strictement
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier
électronique et supprimez ce message ainsi que toutes les pièces jointes.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine