[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Calling augtool from a script



On 24 Apr 2013, at 3:50 PM, Raphaël Pinson <raphael pinson camptocamp com> wrote:

set /files/etc/fstab/1[file='/home/monica/minfrin']/spec "/dev/vg001/home-monica-minfrin2"

This line doesn't really make sense: you're selecting the first entry, but only if its file value is "/home/monica/minfin". I guess you want:

    set /files/etc/fstab/*[file='/home/monica/minfrin']/spec "/dev/vg001/home-monica-minfrin2"

which will update whichever entry matches the condition (not only if it's the first one). If you want only the first entry matching the condition, then use:

    set /files/etc/fstab/*[file='/home/monica/minfrin'][1]/spec "/dev/vg001/home-monica-minfrin2"

This worked, thank you:

augtool -s <<-EOF
set /files/etc/fstab/*[file='/home/monica/minfrin']/spec "/dev/vg001/home-monica-minfrin2"
print /augeas//error
EOF

The entry didn't exist at all (or was not the first entry, as mentioned above), so your "set" command created a "spec" node in the tree, without the other mandatory sibling nodes for a valid fstab entry. When trying to save the new tree to the file, it failed because the tree was not valid.

Does a mechanism exist for the lens to sanity check preconditions, and then return human readable error messages for each condition?

Regards,
Graham
--

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]