Forum: CFEngine Help Subject: Re: split user passwd array Author: tuibelgium Link to topic: https://cfengine.com/forum/read.php?3,24257,24260#msg-24260
Yes I already looked at the solutions guide, but example 1.5 is far from complete. My configuration is now based on exemple 1.6 and it works fine(see first post). As long as you only want to add users and never change them. When you want to change the shell or the home directory you have to use something like: files: "/etc/passwd" edit_line => set_user_field("mark","7","/set/this/shell"); instead of "hard-coding" this I want to use something like files: "/etc/passwd" edit_line => set_user_field("$(user)","7","$(user_shell)"); I want to extract $(user) and $(user_shell) from lines I specified in vars (see my first exemple) Because I could use classes to be selective and do something like: any:: "pw" string => "username1:x:1101:1101:user name:/home/user:/bin/bash"; webserver:: "pw" string => "username2:x:1102:1101:user name:/home/user:/bin/bash"; After that I can easily find, for example, the shell for user2 using this: "dim" int => parsestringarray( "items", "$(pw)", "\s*#[^\n]*", ":", "1000", "200000" ); Now instead of parsing "$(pw)" I want to parse the whole array "pw". I tried "$(pw[$(users)]) but this didn't work. How can i get this working? Or is there some ohter solution for this? _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine