[augeas-devel] Calling augtool from a script

Graham Leggett minfrin at sharp.fm
Wed Apr 24 14:14:11 UTC 2013


On 24 Apr 2013, at 3:50 PM, Raphaël Pinson <raphael.pinson at 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
--

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20130424/032495da/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4365 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20130424/032495da/attachment.p7s>


More information about the augeas-devel mailing list